0), $args)); if($args['debug'] != 1){ error_reporting(E_NONE); } $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("#039;","'",$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); #line break $content = str_replace("[br/]","
",$content); #other tags $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); ob_start(); eval ($content); if($args['debug'] == 1){ $content =(htmlspecialchars($content,ENT_QUOTES)); echo ("
".$content."
"); } $returned = ob_get_clean(); return $returned; } function allow_php_menu(){ add_submenu_page('options-general.php','Allow PHP in posts and pages', 'Allow PHP in posts', 'edit_posts', 'allow-php-admin', 'allow_php_options'); } function allow_php_options(){ ?>

Allow PHP in posts and pages

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

Allow PHP in posts and pages adds the functionality to include PHP in wordpress posts and pages by adding a simple shortcode [php].code.[/php]

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 PHP code to your post or page simply place any PHP code inside the shortcode tags.

For example: If you wanted to add content that is visible to a particular user id:

	[php]
	 global $user_ID;
	 if($user_ID == 1){
	  echo "Hello World";
	 }
	[/php]
	

This code will output Hello World to only user id #1, and no one else

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

     [php debug=1]
      global $user_ID;
      if($user_ID == 1){
       echo "Hello World"
      }
      [/php]
	

Will result in the output:

	
     Parse error: syntax error, unexpected '}', expecting ',' or ';' in XXX : eval()'d code on line 5
     global $user_ID; 
     if($user_ID == 1){ 
       echo "Hello World" 
     } 
	

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.):
     [php]
      echo "hello <br /> world";
     [/php]
	
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.).
     [php]
      echo "hello [br /] world";
     [/php]
	

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 /]