Sanitizing HTML tags in WordPress MU

If you run a WordPress MU installation, you probably notice that there are some HTML tags that are stripped (removed after an entry was posted). For example, when you upload a picture, you want to add style="float: right; margin-left: 10px;" so that you get a better entry formatting.
By default, this style="" is filtered. If you are sure that you want to enable this tag, you can do it easily. Open your kses.php inside wp-includes directory. Around line 20, you will find this line: $allowedposttags = array.
For example:

'img' => array (
'alt' => array (),
'border' => array (),
'class' => array (),
'height' => array (),
'hspace' => array (),
'longdesc' => array (),
'vspace' => array (),
'src' => array (),
'width' => array ()),

alt, border, class, etc. are the code that are permitted to be used in the entry — to me more spesific, inside <img /> tag. If you want to allow style="" in the post, just add a new line: 'style' => array(),. Easy, right?


Comments

6 responses to “Sanitizing HTML tags in WordPress MU”

  1. top ! kemarin ini saya posting image dengan tag style, lalu kok tag tersebut lenyap sehingga layout imagenya juga jadi ngaco. Karena sedang tidak sempat oprek2, akhirnya saya biarkan saja.
    Thanks untuk tipsnya.

  2. apakah itu cuma berlaku pada editor WYISWYG?
    kupikir ( CMIIW ) kalau pakai editor biasa pemasukan inline CSS bisa dilakukan.
    thanks untuk tutorialnya but without thanks.

  3. Harry, iya mas, saya juga ingin mencoba menggunakan pengaturan untuk image… tapi selalu di stripped. Setelah mencoba mencari solusinya, solusi tersebut sudah saya coba. Untuk di ABN, segera akan saya aktifkan secara menyeluruh… Kebetulan upgrade ke WPMU terbaru sudah saya lakukan beberapa hari yang lalu…
    Kus, saya sudah coba keduanya, baik dalam mode rich editor atau yang biasa, tetep saja di stripped. Di WP biasa (bukan MU), memang bisa, tapi di WPMU, katanya demi alasan security, style=”” ini tidak diperkenankan (by default)

  4. OMG! Got dejavu with this!
    While I can’t recommend it if you want to allow images in your comments then make the above changes to the following array:
    $allowedtags = array (

  5. cuma saran :
    kenapa tidak membuat global CSS untuk formating post? Jadi penulis tak perlu masukin sendiri style nya.
    ya paling nggak untuk floating image nya, atau mungkin typogifry?

  6. WordPress should replace their kses with code from this modified version — http://sourceforge.net/tracker/index.php?func=detail&aid=1752954&group_id=81853&atid=564260; it produces more valid HTML, fixes bugs, allows using CSS, etc.