Created
February 23, 2012 17:59
-
-
Save Gipetto/1894045 to your computer and use it in GitHub Desktop.
Convert all category select checkboxes in to radio buttons in the WordPress post-edit screen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert all Category input checkboxes in to radio selects | |
// It completely replaces the elements with new ones and transfers | |
// the attributes from the old element to the new. | |
// We can't just change the type because of, you guessed it, Internet Explorer | |
// Yes, sometimes a hand grenade is easier than a scalpel ;) | |
jQuery('form#post').find('.categorychecklist input').each(function() { | |
var new_input = jQuery('<input type="radio" />'), | |
attrLen = this.attributes.length; | |
for (i = 0; i < attrLen; i++) { | |
if (this.attributes[i].name != 'type') { | |
new_input.attr(this.attributes[i].name.toLowerCase(), this.attributes[i].value); | |
} | |
} | |
jQuery(this).replaceWith(new_input); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Gipetto,
Thanks for providing this useful .js, but I'm struggling to work out where I'm meant to put the code to get it to work?
I'm using WP 3.5, any help would be greatly appreciated.
Regards,
Paul