AJAX 댓글 설정 문제

스크린샷:






로그에 반복적으로 나타나는 오류의 일부입니다:

[2022-04-16 00:08:52] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"} 
[2022-04-16 00:09:06] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"} 
[2022-04-16 00:09:08] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"} 
[2022-04-16 00:09:50] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"}

새로운 게시글을 작성하면 정상 작동하며 주제가 생성됩니다. 그러나 Discourse에서 댓글이 작성되면 WordPress로 동기화되지 않습니다.

위에서 볼 수 있듯이 설정은 크게 변경하지 않았습니다. 제가 무엇을 잘못하고 있거나 놓치고 있는지 아이디어가 있을까요?

다음 가이드를 따랐습니다:

수정:
저도 동일한 오류가 발생하는데, 포럼에서 이것이 유일한 검색 결과였습니다:
comment_formatter.ERROR: format.missing_post_data

이것이 알려진 문제인가요? 아니면 해결할 수 있나요?

안녕하세요,

  1. 가능하시다면, 문제가 발생하는 WordPress 사이트의 게시물 링크를 공유해 주시겠어요?
  2. Ajax 댓글을 사용 중인 특별한 이유가 있나요? (“Load Comments With Ajax” 옵션이 체크되어 있습니다).

안거스, 안녕하세요.

  1. 네, 물론이죠: 60 Linux Networking commands and scripts | LinuxBlog.io (현재 동기화된 게시글은 이것뿐입니다)
  2. 여러 가지가 제대로 작동하지 않는 상황이 몇 시간째 이어지자, 어쩔 수 없이 Ajax를 마지막 수단으로 확인해 보았습니다. 지금은 Ajax를 해제해 두었습니다. 웹훅(Webhooks)이 없으면 동기화 간격이 다소 걸렸던 것 같습니다.

이제 작동하는 것 같지만, 포맷이 좀 우아하지 못합니다. CSS를 직접 찾아봐야 할 것 같습니다.

또한, 구형 WP 블로그 게시글에 대해 “토론에 참여하기” 같은 링크를 저희 Discourse 포럼 홈페이지로 표시할 수 있는 방법이 있을까요? - 다시 말해, 게시글에 댓글이 없거나 게시글이 이전에 Discourse로 동기화되지 않은 경우, 빈 공간으로 두는 대신 플러그인이 제 Discourse 포럼 홈페이지로 가는 일반 링크를 추가하도록 하는 것입니다.

도와주셔서 정말 감사합니다.

네, 표시 방식은 테마에 따라 달라집니다. 플러그인 자체에는 최소한의 스타일링만 적용되어 있습니다.

연결되지 않은 주제에는 “토론에 참여하기” 링크가 표시되지 않습니다. 플러그인과 별개로 테마의 functions.php 파일에서 comments_template 필터를 사용하여 직접 추가할 수 있습니다. 이 코드는 테스트하지 않았지만, 다음과 같은 코드가 작동할 것입니다:


use WPDiscourse\Utilities\Utilities as DiscourseUtilities;

function non_discourse_comments_template( $comment_template ) {
   global $post;
   $post_id = $post->ID;
   $discourse_post_id = get_post_meta( $post_id, 'discourse_post_id', true );

   if ($discourse_post_id) {
     return;
   } else {
     $options = DiscourseUtilities::get_options();
     $discourse_permalink = $options['url'];
     $link_text = "토론에 참여하기";
     return '<div class="wpdc-join-discussion"><a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '" target="_blank" rel="noreferrer noopener">' . esc_html( $link_text ) . '</a></div>';
   }
}
add_filter( "comments_template", "non_discourse_comments_template" );

추가로 도움을 주셔서 다시 한번 감사합니다!

레이아웃을 조금이라도 개선할 수 있도록 붙여넣을 CSS를 찾아보고 있습니다.

다만, CSS/스타일링에 익숙하지 않아서 (기존 CSS를 붙여넣는 것 외에는) 가져온 댓글의 스타일에 아주 기본적인 수정을 하고 싶습니다. 구체적으로는, 댓글에 있는 discourse 사용자 이름 옆에 더 작은 아바타 이미지를 사용하고, 게시물 사이에 수평선을 추가하는 것입니다:
image

/admin/customize/themes/1/common/scss/edit 에 코드를 붙여넣으면 될 만큼 간단한 작업인가요?

수정:
다른 분들을 위해 공유하자면, 다음 코드를 사용하여 gravatar 리사이즈 문제를 해결했습니다:

댓글 스타일을 지정할 수 있었습니다. 아주 기본적인 스타일링이긴 하지만 lol… 그래도 개선된 점은 있습니다.

남은 작업은 WP-Discourse에서 가져온 댓글 섹션 하단의 참가자 목록을 제거하는 것입니다.

이 코드를 사용할 수 없는데, "self"를 사용했기 때문에 오류가 발생합니다. 우회 방법이 있을까요?

ob_start();
?>
<div id="comments" class="comments-area discourse-comments-area">
<div class="comments-title-wrap">
<h2 class="comments-title discourse-comments-title"><?php echo esc_html( self::get_text_options( 'notable-replies-text' ) ); ?></h2>
</div>
<ol class="comment-list">{comments}</ol>
<div class="respond comment-respond">
<h3 id="reply-title" class="comment-reply-title">
<?php echo esc_html( self::get_text_options( 'continue-discussion-text' ) . ' ' ); ?>
<?php self::discourse_topic_link( self::new_tab() ); ?>
</h3>
<p class="more-replies">{more_replies}</p>
</div>
</div>
<?php
$output = ob_get_clean();

다음 줄들을 제거했습니다:

<div class="comment-reply-title">
<h4 class="discourse-participants"><?php echo esc_html( self::get_text_options( 'participants-text' ) ); ?></h4>
<p>{participants}</p>
</div>

하지만 “self” 문법 오류는 어떻게 해결해야 할지 모르겠습니다. 특히 다음 줄들이요:

<?php echo esc_html( self::get_text_options( 'continue-discussion-text' ) . ' ' ); ?>
<?php self::discourse_topic_link( self::new_tab() ); ?>

저는 참가자 섹션을 제거하지 않았습니다. 제거를 고려 중이시라면, 다른 Discourse 기능들과 마찬가지로 한 번 시도해 보시길 권합니다. 개발진이 이 부분에 대해 상당한 고민을 했기 때문입니다. 게시글 15개 중 5개만 가져와도 모든 참가자가 표시됩니다. (설정 변경 가능) 또한, 가져온 응답에는 레벨 0 포럼 멤버의 게시글이 제외됩니다. 이는 유용하다고 생각합니다.

요약하자면, 시간이 지나면서 참가자 목록과 가져온 댓글이 항상 동일하지 않다는 것을 알게 되었습니다. 많은 경우, 모든 게시글을 가져오지 않거나, 가입 초기 멤버의 게시글을 가져오는 위험을 감수하지 않으면서도 블로그 독자에게 댓글 활동 수준에 대해 더 정확한 시각을 제공해 주는 데 도움이 됩니다. (이것도 설정에서 변경 가능하다고 생각합니다)

I think the comment_formatter.ERROR: format.missing_post_data is being over eager in its reporting. I’ll tweak that for the next release. Thanks for following up about it. I wouldn’t worry about it for now, unless you’re experiencing a visible issue.

There isn’t a formal guide on comment styling. There are a few other topics, e.g. this one. Wordpress themes come in so many shapes and sizes that it was initially thought to leave this up to the site admin. That said, I think some additional guides may be useful.

I’ve put it on my list to add to the WP Discourse guides. I won’t publish that for a few weeks, but if you get stuck with styling in the meantime let me know and I’ll give you some pointers.