WordPress: Vanilla integration is boogering up comment counts that are WordPress native comments
Hi,
I'm using the following:
WordPress 4.1
Vanilla plugin for WordPress 1.1.14
Vanilla forums 2.1.8p2
Firefox
I have gotten integration between a self hosted instance of Vanilla and WordPress working pretty well, including shared logins and forum embedding within a dedicated WordPress page.
Now, there is one significant bug I am experiencing. Even with Vanilla comment integration (which I do not want) turned OFF in WordPress, the comment counts are messed up in every single blog post on the site. Every single one displays as no comments.
The commenting box that is displayed in the WordPress blog is the WordPress native comment box.
What happens when a page containing any blog posts is displayed is that: I first see the correct comment count display at the top of the blog post, and then it is immediately overwritten (as I watch) with the label "No comments". It looks like Vanilla's integration code is using Javascript to whack the comment count HTML to display the Vanilla equivalent. It's happening just slow enough that I see it change.
The HTML that I see in the Firefox inspector after this happens looks like this:
<span class="entry-comments-link"> <a href="http://mysite.com/name-of-blog-post/#vanilla-comments"> <span vanilla-identifier="2745"> No Comments </span> </a> </span>
Because the Vanilla code has garbaged the URL for the comments with a non existent #vanilla-comments address, the comments can't be clicked by the user.
If I examine the Page Source, the original HTML that is apparently being overwritten looks like this:
<span class="entry-comments-link"> <a href="http://mysite.com/name-of-blog-post/#comments"> <span vanilla-identifier="2745"> 23 Comments </span> </a> </span>
A fix, please? I apologize if this has been discussed... I did not find any other threads discussing this issue.
Thanks.
Comments
OK, I stepped through the JavaScript with the FireFox debugger and I located the code where the DOM is being modified. In js/count.js, I inserted the following early return statement:
function vanilla_assign_comment_counts_by_tag(data, tagName) { return; // <<-- mine if (typeof vanilla_comments_none =="undefined") vanilla_comments_none = 'No Comments';
This stuff shouldn't even be getting executed because I don't have Vanilla commenting enabled in this blog. But blogs at least keep the correct comment counts now.
Thanks for posting back with your solution!
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Thank you very much for your solution HackerDon, saved me a lot of headache!