Maybe I’m too “old fashioned,” but I’ve often wished I had a button on my WordPress editor that I could use to easily add a good-ol’ <hr>.
There are some other options that users may want, too. The stand-by plugin solution for this is the TinyMCE Advanced. It adds a number of extra features along with additional editor buttons — including my <hr>.
The problem I found with this particular plugin is similar to others. It comes with junk I don’t want or need, sometimes conflicts with WordPress’ native behavior, and plugin bloat is never a good thing!
Here’s how you can manually add only the additional editor buttons you want.
Add Visual Editor Options
Can you guess where we’re going to drop this code?
If you read yesterday, I’m sure you already know!
You’ll place this in your functions.php, and just like before, you can always package this into a plugin form or bundle it with other WordPress hacks you have tucked away in your custom plugin.
[cc lang=”php”]function enable_more_buttons($buttons) {
$buttons[] = ‘hr’;
/*
Repeat with any other buttons you want to add, e.g.
$buttons[] = ‘fontselect’;
$buttons[] = ‘sup’;
*/
return $buttons;
}
add_filter(“mce_buttons”, “enable_more_buttons”);[/cc]
Easy, right!?!
Here is a list of all the available buttons:
Bold, italic, underline, strikethrough, justifyleft, justifycenter, justifyright, justifyfull, bullist, numlist, outdent, indent, cut, copy, paste, undo, redo, link, unlink, image, cleanup, help, code, hr, removeformat, formatselect, fontselect, fontsizeselect, styleselect, sub, sup, forecolor, backcolor, charmap, visualaid, anchor, newdocument, and separator.
Now, let’s get a little fancy.
The first example adds my beloved <hr> to the first row of buttons. If you want to add a second or third row, repeat as before, but with the changes here:
[cc lang=”php”]add_filter(“mce_buttons_2”, “enable_more_buttons”); // add to second row
//add_filter(“mce_buttons_3”, “enable_more_buttons”); // add to third row[/cc]
How fancy are you?
This is a picture perfect way to add some functions you maybe missing, without the heavy, and sometimes touchy, TinyMCE Advanced plugin.
[via Sycha]
Renji says
Nice tip. Anyway to get some buttons in HTML editor using functions?
Eric Dye says
Not sure on that one … yet 😉