How to enable or use Javascript and Flash embed in WordPress MU

WordPress Mu
Whenever I enter Javascript tags like <script>...</script> in the WordPress MU posts, they will disappear. The same thing is with the <object>..</object> and other HTML tags. I understand they got stripped by some filter codes due to the consideration of web security. But I need such tags badly since I have a lot of YouTube videos need to be embedded which come with <object> tags, and some Javascript tags too (like the countdown image from Ubuntu in my previous post).

What are the solutions? I could not find any official solutions from the support forum of WordPress MU website. Someone recommends to put the Javascript text in sidebar, or download some plugins to do so. Since I need to show videos in my posts, the widget sidebar one can not be good to me. I decide to change filter code file which was not my best choice though.

The file is located in /wp-include folder and the name is kses.php.

The quick way is to comment out the following two lines at the end of this file:

add_action(‘init’, ‘kses_init’);
add_action(‘set_current_user’, ‘kses_init’);

But in this way, all new posts and comments will be able to have powerful HTML tags like <script><object>. I trust myself since I am the owner and author for all my blogs in WordPress MU, but I do not trust all comment users.

So I guess it will be a better way to only add tags in the global variable of $allowedposttags. In line 184 of kses.php file, I added the following lines to allow my posts to have <script><object> tags.

//added by WebGuru on 2007-10-06
‘script’ => array(
‘type’ => array(),
‘src’ => array()
),
‘noscript’ => array(

),
‘object’ => array(
‘height’ => array(),
‘width’ => array(),
‘type’ => array(),
‘data’ => array(),
‘allowfullscreen’ => array(),
‘id’ => array()
),
‘param’ => array(
‘name’ => array(),
‘value’ => array()
),
‘embed’ => array(
‘width’ => array(),
‘height’ => array(),
‘type’ => array(),
‘src’ => array()
)

With the above addition, it is enough for the purposes of posting YouTube videos and other Javascript codes. Of course, if someone can make a plugin to do so instead of modifying the core fiels please let me know and I would like to use this plugin.

  • Share/Bookmark
No tag for this post.

Related posts

7 Responses to “How to enable or use Javascript and Flash embed in WordPress MU”


Leave a Reply



Get Adobe Flash playerPlugin by wpburn.com wordpress themes