Yop Poll WordPress plugin: Changing class of button and add FontAwesome

Since moving over to a new theme on the works web site, it’s been my mission to change the INPUT and BUTTON tags to match, and sometimes it’s just not possible without massive duplication of CSS.

In this morning’s example, I wanted to get rid of the styling imposed by Yop Poll and put Twitter Bootstrap’s btw classes in it’s place, and I’m not in the mood for a little thing like a lack of customisation or specifying classes beat me.

We want to look at this section.
jQuery(document).ready(function(){
runOnPollStateChange_%POLL-ID%();
});

The id button is #yop_poll_vote-button-%POLL-ID% in the template so the jQuery script is:

jQuery( "#yop_poll_vote-button-%POLL-ID%" ).removeClass( "yop_poll_vote_button" ).addClass("btn btn-default");

Ta-dah! But we’re not going to stop there. We use FontAwesome, it would be nice to have that as well wouldn’t it? Well let’s do it, using the same ID, we can just prepend to the HTML in the button.

jQuery("#yop_poll_vote-button-%POLL-ID%").prepend('<i class="fa fa-check-square-o"></i>');

And if you are going to ask how to put the icon AFTER the text then you should be ashamed of yourself and step away from WordPress!

And in the words of Jimmy Saville (whoops, probably triggered someone there), “how’s about that then.”

Leave a Reply