Here’s a quick one if you are in need of a noon-time distraction. If you’ve ever used the WYSIWYG editor TinyMCE, called “tiny mice” by some, then you know that it likes to
hook() up with every
that it sees.
The results of this promiscuity range from annoying (I don’t need a HTML editor for a log message!) to the disastrous (?*$! That HTML editor just stripped the newlines from my list of pages in “Page specific visibility settings!” Oh, the humanity!)
The fix for this is hinted at in the docs of TinyMCE. You can specify a list of named
textareas for TinyMCE to ignore from inside the theme function,
phptempate_tinymce_theme(). For each named
, you can unset the TinyMCE
$init. Which is somewhat useful, but everytime you add a new module, you’ll find a new list of
s that get screwed up.
However, to really control TinyMCE, we can turn that logic on its head. If we use that theme function to specify a list of named
s that will pass untouched through the function (meaning TinyMCE will hook up with them) and unset the TinyMCE init for all other
s. Here’s the code:
And voila! TinyMCE will now only hook up with node bodies, block bodies and comments.