0), $args)); if($args['debug'] != 1){ error_reporting(E_NONE); } /*Strip out the Poor Tags*/$content =(htmlspecialchars($content,ENT_QUOTES)); $content = str_replace("’","'",$content); $content = str_replace("‘","'",$content); $content = str_replace("′","'",$content); $content = str_replace("“","\"",$content); $content = str_replace("”","\"",$content); $content = str_replace("″","\"",$content); $content = str_replace("'","'",$content); $content = str_replace("'","'",$content); $content = str_replace("&","&",$content); $content = str_replace("<br />"," ", $content); $content = htmlspecialchars_decode($content); $content = str_replace("
"," ",$content); $content = str_replace("

"," ",$content); $content = str_replace("

"," ",$content); $content = str_replace("[br/]","
",$content); $content = str_replace("\\[","[",$content); $content = str_replace("\\]","]",$content); $content = str_replace("[","<",$content); $content = str_replace("]",">",$content); $content = str_replace("[",'[',$content); $content = str_replace("]",']',$content); $content = str_replace(">",'>',$content); $content = str_replace("<",'<',$content); /*Buffer the output*/ ob_start(); echo ""; if($args['debug'] == 1){ $content =(htmlspecialchars($content,ENT_QUOTES)); echo ("
<script type='text/javascript' >".$content."<script/>
"); } $returned = ob_get_clean(); return $returned; } function allow_js_menu(){ add_submenu_page('options-general.php','Allow Javascript in posts and pages', 'Allow JS in posts', 'edit_posts', 'allow-js-admin', 'allow_js_options'); } function allow_js_options(){ ?>

Allow Javascript in posts and pages

Developed by Hit Reach Check out our other Wordpress Plugins Version: 0.0.1 Support, Comments & questions

Allow Javascript in posts and pages adds full functionality for javascript in wordpress posts and pages by adding a simple shortcode [js].code.[/js]

This plugin strips away the automatically generated wordpress <p> and <br/> tags but still allows the addition of your own <p> and <br/> tags

Usage

To add the Javascript code to your post or page simply place any Javascript code inside the shortcode tags.

For example: a simple alert

	[js]
	 alert('helloWorld');
	[/js]
	

This code will cause a popup when the page is loaded

in addition, should this code not be working (for example a missing ";") simply just change the [js] to be [js debug=1]

     [js debug=1]
      alert('helloWorld');
      [/js]
	

Some Important Notes

This plugin strips away all instances of <p> and <br /> therefore code has been added so that if you wish to use tags in your output (e.g.):
     [js]
      alert("hello <br /> world");
     [/js]
	
the < and > tags will need to be swapped for [ and ] respectively so <p> becomes [p] and </p> becomes [/p] which is converted back to <p> at runtime. these [ ] work for all tags (p, strong, em etc.).
     [js]
      alert("hello [br /] world");
     [/js]
	

Tag list

For Write as
<p> ... </p> [p] ... [/p]
<em>...</em> [em]...[/em]
<p style=''> ... </p> [p style=''] ... [/p]
<u> ... </u> [u] ... [/u]
<br /> [br /]