I was looking for a WordPress upvoting plugin today. Something a little more than a like button; there are plenty of those. I wanted to find something that would re-order blog posts based on votes as well. That is a little harder to find.
I found this via GitHub (thanks John Shroff whoever you are). But, it doesn’t re-order posts. I proceeded to add functions to this plugin to order posts by votes. After hours of fiddling, I thought I succeeded.
I was able to upvote and downvote and it seemed like the posts were then changing their order. But, eventually, depending on the type of IP address (IPv4 vs IPv6) and/or maybe just due to a bad post-order query, it broke. As in, certain posts stopped fully loading. It started to get confused about which votes to associate with which posts.
I’m leaning towards the culprit likely being the custom sort order SQL query I added. When I removed all of the code related to that, the error went away. For a moment I did think it could have to do with IPv6 addresses being stored wrong and so I changed that part of the code following the advice here. So that the right type of column is created in the database which works for either IPv4 or IPv6. But, that may or may not be part of the problem.
For now I’m abandoning this plugin. These things happen. Today just wasn’t meant to be the day I figured this out. I’ve uploaded it to this GitHub repository. Should any developer stumble upon this post and feel like making something with this, go for it.
I’m creating a new repository instead of submitting a pull request to the repository I originally found for obvious reasons. I didn’t finish fully testing the few changes I made. Yet, I still want to put this version with some minor tweaks out there for the good of open source.
So, for anyone good at making WordPress plugins, I do think this pretty much works. Feel free to adjust things and make it better.
Here’s what it looks like: