Developed by Hit Reach

Please check out our other WordPress Plugins

Plugin Support, Comments & Questions

Please help! We need your support...

If this plugin has helped you, your clients or customers then please take a moment to 'say thanks'.

By spreading the word you help increase awareness of us and our plugins which makes it easier to justify the time we spend on this project.

Please help us keep this plugin free to use and allow us to provide on-going updates and support.

Here are some quick, easy and free things you can do which all help and we would really appreciate.

  1. Promote this plugin on Twitter
    ' border="0" width='55' height='20'/>
  2. Link to us
    By linking to www.hitreach.co.uk from your site or blog it means you can help others find the plugin on our site and also let Google know we are trust and link worthy which helps our profile.
  3. Like us on Facebook
    Just visit www.facebook.com/webdesigndundee and hit the 'Like!' button!
  4. Share this plugin on Facebook
    Share a link to the plugin page with your friends on Facebook
  5. Make A Donation
    Ok this one isn't really free but hopefully it's still a lot cheaper than if you'd had to buy the plugin or pay for it to be made for your project. Any amount is appreciated

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

This plugin attempts to strip away the automatically generated wordpress <p> and <br/> tags but still allows the addition of your own <p> and <br/> tags using a form of BBcode items such [p][/p] and [br /]

You can also save your most used bits of code as snippets for use across multiple pages.

With Version 2.2, the older tag replacement system has been revamped, hopefully reducing the need to escape some characters for example: [ and ] that shouldnt be changed &lt; and &gt;

With Version 2.3 comes an experimental advanced filter feature which allows you to use standard php code while taking advantange of variables thoughout the entire post content, and functions, as well as no pesky tag replacement.

With Version 3 comes entirely re-written code with support for code snippets being used in conjunction with the advanced filter feature as well as a class variable to share variables between saved snippets and code blocks. This version also comes with UI updates.

Usage

Using the plugin couldn't be simpler; the plugin has 2 variants of shortcode available, [php] and [allowphp]other versions of the shortcode may exist but are not fully supported.

To add the PHP code to your post or page simply place any PHP code inside the shortcode tags as follows:

[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

The shortcode can take a some additional attributes to assist with PHP writing

Code Snippets

In addition to these attributes, a new one has been added called "function". The function attribute allows the addition of user defined code snippets into the content. The shortcode for snippets is <code>[php function=x]</code> or <code>[allowphp function=x]</code>

To integrate the snippets with the advanced filter, the shortcode should not contain any additional attributes or spaces

Code snippets can be added in the plugin's options page and can be re-used on as many pages as you like

Advanced Filter

The advanced filter is the newest feature of the plugin.

It allows the user to write standard html directly into the html post editor without needing tag replacements.

There are 2 ways to enable the Advanced Filter, the easiest way is to enable it in the plugin options page, the other way is to add "useadvancedfilter"onto the standard shortcode to use it on a shortcode by shortcode basis:

[php useadvancedfilter]...[/php useadvancedfilter] or [allowphp useadvancedfilter]...[/allowphp useadvancedfilter]

Variable Sharing

The plugin class contains an array with can be used to share variables around the page, between blocks of php code anywhere.

Variable delarations can be made by accessing the global variable $allow_php as follows:

[php]
	global $allow_php;
	$allow_php->_shared['my_key'] = 'my value';
[/php]
This code will set "my value" to index "my_key" within the shared array
[php]
	global $allow_php;
	echo $allow_php->_shared['my_key'];
[/php]
This code will output the index "my_key" within the shared array

This can be useful for passing post information to the sidebar :)

For more information about the plugin or for any question please go to the plugin support page