making bbPress (and WordPress) work better!

How to “de-ajax” WP-Polls 2.11 & 2.12

WP-Polls is a great voting plugin for WordPress but after version 2.06b Lester decided to use ajax (only).

While ajax is the latest buzzword, ajax is not very handy if you want bookmarkable pages and despite what people are led to believe, it actually can put *more* load on the server. It also makes certain kinds of tracking difficult (or impossible). Worse yet, if visitors have javascript disabled, it won’t work at all. So if it’s not critical, I don’t like to use ajax.

While you can just use 2.06b if you don’t want ajax, the problem is he added some nice little features after that version (like tracking votes by member instead of IP) which you may want.

The good news is it’s not hard at all to make it non-ajax. I hope to release a mod of 2.12 at some point (if he doesn’t do it first) that lets you toggle between ajax and non-ajax with a simple admin menu choice, but for now here are the steps to undo the ajax features manually and make it static, exactly like 2.06b

1. The only file you have to modify is “polls.php” which should be in your plugins/polls folder

open that in your favorite plain text editor (ie. notepad)

2. around line 29 you’ll see add_action('wp_head', 'poll_header');
comment that out (disable it) by putting two slashes in front of it. ie. // add_action

3. around line 474 find the line that says
} elseif (intval($_GET['pollresult']) > 0) {
in front of that, start a comment block (disable several lines) by putting a slash and asterik in front ie. /* } elseif

4. around line 481 where it says
} // End if(!empty($_POST['vote']))
end the comment block with a asterik and a slash ie. */ } // End if

5. Go into your WP admin menu , then Polls, then Poll Options

6. do down to the third box that is labeled “Voting Form Footer” and change the text that says: type="button" name="vote" value=" Vote " class="Buttons" onclick="poll_vote(%POLL_ID%);" /><br /><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;"

to:

type="submit" name="vote" value=" Vote " class="Buttons" /><br /><a href="%POLL_RESULT_URL%"

7. go down to the SECOND “Result Footer” template setting where it says
Displaying Of Vote Poll Link If User Has Not Voted
and simply replace it with the text that is in the field above it for the regular result footer.
(There may be some code we can substitute in the future for the same functionality but right now we just want to restore 2.06b emulation.)

8. replace polls.php back on your server and it should be de-ajax’ed!

5 responses

  1. rendra

    Hey…Thanks for your post about de-ajax wp-polls.I am try your tutorial but i think i am still get it ( wp-polls 2.21 ) if any that i missed from your tutorial?????

    I am using wp 2.3, sorry for my english

    November 17, 2007 at 1:06 pm

  2. cal

    hello,

    i need some help on getting wp-polls to run on IE 7.0. it works on all platforms
    but not with IE 7 (i cant see the results, it only fades out after doing a vote,then
    theres no result showing up.

    any suggestions?

    November 18, 2007 at 12:48 pm

  3. rickjo

    Hi! You´re the only guy on the whole of the internet that actually covers this brilliant issue (believe me, I’ve just spent the whole night searching)! Thanks a lot, really!!

    But I have one question… Could you not help us through de-ajaxing wp-polls 2.20? Because I was able to do it to the versions you teach about here, but I need to do a 100 answers poll and these versions here only go up to 20. And aplying these steps on the 2.20 version makes it not work… so any chance of helping out…? 😉

    Thanks!!!!

    December 12, 2008 at 9:45 pm

  4. Even better, I’m the only *gal* on the whole internet covering this 😉

    But unfortunately it’s been years since I’ve looked at Lester’s (GamerZ) plugins since I started writing my own.

    Did 2.20 really change that much from 2.12 ? I know that once he discovered ajax he tended to go overboard which was probably one of the reasons I started to write my own.

    If all you need is 100 answers, why not take the patched 2.12 version and find the 20 limit and hack it to 100? From what I can see, 2.14 was the last of the 2.1x more minor updates before he jumped to 2.20 so maybe use that if my patch still works:
    http://plugins.trac.wordpress.org/browser/wp-polls/tags
    Search for things like " <= 20 " or " > 20 "

    December 13, 2008 at 5:57 am

  5. Another problem is I think WordPress.com “ate” some of my instructions because of the html code. Unfortunately WP.com is not very code sharing friendly and I don’t have the original instructions anywhere else.

    December 13, 2008 at 6:05 am

Leave a reply to rendra Cancel reply