In the case of WP MU, the best solution that I could find does include a plugin – but you can write it yourself in about 10 seconds. In writing the plugin yourself, you will also know how to maintain it yourself. Even if you don’t know much about PHP, this one’s a piece of cake!
So, here’s how to convince WordPress MU to play nice with the HTML in your posts…
Okeydokey. If you know PHP, this is a no-brainer. If you don’t know PHP very well, you’re going to have to be able to do three things:
- Create a text file with a .PHP extension
- Paste some text I’m going to give you into the file
- Upload it to a particular directory on your server
Sounds pretty hard, right?
I should note that the code I’m about to give you is my modified version of the Allow Embedded Videos plugin for WP MU. The author himself collected bits and bobs from other suggestions and just compiled them into a plugin. The plugin also comes with Update Notifications, which is a plugin/theme update-checker for plugins and themes from wpmudev.org. I decided this was kind of annoying and unnecessary for the little plugin I needed, so I’m just using the “Allow…” plugin itself, and I’ve added my own little tweaks.
So, here we go:
Create a new file and call it whatever you want – something like:
Edit that file and paste the following code:
Now save the file, and upload to:
[Your WordPress MU Directory]/wp-content/mu-plugins/
Now, WP will automatically pick up the file, and add the “anti-filter”. Note that the first lines of the plugin file are necessary for WordPress to be happy with it as a plugin. You can change the plugin info to whatever you want.
The rest of the code is pretty simple. All it’s doing is saying:
For each of these object, param, embed, script, and input tags, allow them and the following parameters for each…
<script> tags with “
type=“, and “
language=” parameters are now allowed. Before, they would have been filtered out by the more strict post sanitizer in WP MU.
You could also now include PayPal buttons on your WordPress MU pages, since
<input> tags will no longer be sanitized, either. And you can add as many tags as you want this way. Just add a new section to the
$content array, just like I did for ‘script’ and ‘input’ tags.
In my case, I’m simply using WP MU to host one site in multiple languages, so I don’t have to worry about people trying to do Evil Things when posting content!
Finally, I would like to mention that using WP MU is otherwise extraordinarily easy, and if you ever have to make a multi-lingual site, don’t bother with any of the plugins out there. They are all inherently flawed to one extent or another.
Using WP MU, you can simply export your content, upgrade your normal WP install to WP MU, import your content, and configure subdomains like “es.awesome-blog.com”, “fr.awesome-blog.com”, and so on (see instructions here).
Each blog will have its own admin backend, but you can manage them all yourself. Each language/blog also gets its own set of tables in the database. Cool!
And, since WordPress 3.0 will basically merge WP and WP MU, you’ll be nice and future-proof, too.