I'm nearly finished with the design of my new WordPress voting site, WPVote, so now need to look more closely at the programming.
I enjoy dissecting WordPress themes, and since I also like code simplicity and minimalism (and am working with a child theme) I decided to strip out as much of the original WPVote theme as possible.
First I had to go through the theme files and work out which were normal theme files (archives etc) and which had special stuff going on (the voting functionality). I could then drop any files that duplicated functionality in Elemental.
Next I joined what was left into functions in the child themes functions.php. I was left with half a dozen files making things a lot easier to manage.
JavaScript isn't one of my strong points but I like to learn new skills so swapped all the dynamic/ ajax functionality over to jQuery (before it was custom coded). This included the Ajax code - which is something I have I have even less experience with.
The original theme used WordPress custom page templates for the login and registration screens but I wanted to use the fewest number of files possible to make things as easy to set up as I could.
The reasoning behind this is that if I end up turning this theme into a premium theme then anything I can remove from the setup process is one thing extra that I don't have to support.
What I did instead was use lightboxes with ajax pop-up windows for both the login/ registration screens and the article submission screen.
For the lightbox (and tabs, and tooltips etc) I went for the jQuery Tools library, which I also use extensively here on Binary Moon. It's a really complete jQuery add-on and covers all the things I need for the average website. I'd recommend it.
The article submission page on the old WPVote site used the TDO mini forms plugin. It's a cool system but, again, this would mean something else for people to set up, and supporting someone elses code is not something I want to do.
Luckily I was once working on a theme and plugin that were not released - it was a plugin version of the post submission element of the Prologue theme (now known as P2). So, I spent about an hour modifying that to fit the new WPVote theme. The big advantage of doing things myself is that I know how things work and am not relying on other developers.
Because so many elements of WPVote are publicly accessible security is a big aspect of the development and I am now looking at ways to harden up the data entry and make sure bots can't be set to hack/ spam the site.
WordPress has a lot of security related functionality built-in, there's a page on validating data input on the WordPress Codex which I have found really handy. I also intend to use Nonces to prevent unauthorised article submissions, along with CAPTCHA (which Elemental supports natively), and I am considering support for Akismet to stop spam entries in their tracks.
Additional functionality I will be adding are some new WordPress Widgets, to make the site customisation easier, and some new Dashboard Widgets for logged in users.
Next I will be looking at making the transition to a live site. Is there anything else I should consider adding/ developing that I might not have thought of?
5 Responses to “Building WPVote Part 5 : Programming” Leave a reply ›
why must be build theme as theme ben?, i`m sure this stuff will be more popular as pluggins
Hey William - The main reason is that there's a lot more to the theme than just the voting and other things that could . A lot of the functionality would require making changes to the theme files to integrate all the options so it makes sense (to me) to release it as a theme.
Secondly, I have had a lot of people ask me for a theme, and so far nobody has requested a plugin. The people I have spoken to want to have something they can just upload and use, rather than have to set up themselves.
I am developing a consumer complaints website using wordpress. I intend to use wp_insert_post function to create posts from user submitted complaints.
Recently I checked WPVote which is a similar website, except that users have to register before they post content. My question is, why you made registration mandatory?
Looking forward to your reply.
Thanks
Hi Mayur - thanks for the comment. Registration was made mandatory on WPVote essentially to prevent spamming. Technically I could have allowed open post submission, but I didn't want to have uncontrollable floods of posts from people advertising all the things they advertise in blog comments. Registration also helps control the voting aspect. I didn't want people to try to trick the voting system into giving false votes. With open voting it would generally be a case of clearing cookies and voting again, but with registered voting it is quite easy to track which users voted for which article.
Thanks for clarification