senlin / multilingual-comments-wpml

This plugin combines comments from all translations of the posts and pages using WPML. Comments are internally still attached to the post or page in the language they were made on.
GNU General Public License v3.0
0 stars 0 forks source link

Comment not showing when comment is made on secondary language #3

Closed emliron closed 9 months ago

emliron commented 9 months ago

Hello, My site is bilingual French/English< (Enfold theme and WPML). The plugin works perfectly when there are comments in both languages. However, if there are no comments on the English article, for example, and one comment on the French article, the English article doesn't display any comments, even though the number of comments (1) is correct.

see: https://www.assopogo.net/en/engine-training/#comment-2897

senlin commented 9 months ago

Hello @emliron

Strange, I tested your scenario on a vanilla sandbox site and it works as it should.

To reproduce I made a new post in default language English, and translated it in 3 languages (Dutch, German, Chinese). I then left a comment on the German post and this comment shows on all languages: https://sandbox-online.com/wpdev/de/test-ml-comments/ (scroll down for languages switcher).

So if this is not working at your end, then I'm afraid it must be something related to the Enfold theme?

emliron commented 9 months ago

Hello Pieter,

Indeed, I think it has to be related to the theme. I'm going to try to do a test with another theme very early in the morning!

I've looked at the script, I understand the idea, but not the syntax of the 'comments_clauses' hook. I could try another approach, by simply redefining the clauses in the hook with a new function.

Emmanuel

senlin commented 9 months ago

Hi Emmanuel,

The comments_clauses hook filters the comment query clauses (WP Reference). There is actually quite a bit of information on this hook, for example here.

For this plugin to do its work, it is necessary to tell WPML to also look at the Post IDs of the translation(s) of this Post. So in L78 the filter is first removed and then the conditions are set (L80-L95). Then on L97 the filter is added back so that when L99 fires, comments in all languages are returned.

Hope that explains it a little.

I will close this issue for now, if you find anything that might help other people, please feel free to re-open.

Good luck! Pieter