WordPress.org

Plugin Directory

PHP Code for posts

Add PHP code to your WordPress posts, pages, custom post types and even sidebars using shortcodes

Currently in rapid deployment testing - fixing bugs and quirks with older versions of PHP

PHP Code for posts allows you to add your own PHP code to posts, pages, custom post types (posts) and even sidebars without the need for custom templates

The plugin enables a shortcode and options page so you can add your code to the admin options page and then output it in your post using shortcodes

Multiple code snippets can be used on a post, and multiple posts can use the same code snippet, allowing you to re-use code.

The shortcodes can be used to also display plain HTML content, allowing you to add in iframe, objects, areas and other tags that are removed by the post editor

The plugin also contains a variable array which you can add variables to for use between snippets called $_var and is available though the global variable $PHPPC which is an object, so its $PHPPC::$_vars[]

Parameter Variable Extraction: When this option is enabled, you will be able to access the parameters passed to a snippet using their name. For example in the snippet [php snippet=x param=test=hello] you will be able to directly access $test in your code snippet for the value of "hello", rather than needing to do $_parameters["test"]

It is important that the PHP Variable Naming Conventions are followed when using this option otherwise it could have some unexpected results. (see: http://php.net/manual/en/language.variables.basics.php)

New for 1.1.1

The plugin's shortcode can also accept parameters using the param attribute, the value should be a string of name=value pairs, separated by &s, for example [php snippet=2 param="var1=val1&var2=val2"]. Within your snippet, the parameters are assigned a $_parameters array, for example echo $_parameters["var1"]; //outputs "val1"

New for 1.2.0

The plugin's snippet editor now has better formatting, and supports AJAX saving for snippet updates (request by eneasgesing)

New for 2.0.x

  • Refreshed interface
  • Custom shortcode name
  • Translation support
  • Expansion of the parameter system

New For 2.1.x

  • Multisite!

Multisite update comes with more options to make handling your multisite setup simplier.

These options can only be changed on blog id 1 (the master site)

  • New Options

Allow Custom Snippets for sub-sites?

This option allows you to enable or disable the ability for sub-sites to create, edit and use their own snippets

Allow sharing of snippets between sites

This option allows you to enable or disable the ability for sub-sites to share their own snippets and to use other sub-site's snippets via the new shortcode

Allow per-site options for multisite

This option allows you to enable or disable the ability for sub-sites to change options specific to their site such as the main shortcode, and ajax saving

Change the multisite Shortcode.

In keeping with the ability to change the original shortcode, this opion allows you to change the new multisite shortcode to what ever you fancy. Just don't try making it the same as the single site, it wont work!

  • New Shortcode

With the new multisite comes a new shortcode.

This shortcode allows the loading of shared snippets from other members of your multisite setup.

Simply pass the blog_id and the snippet to load, and if the snippet exists and is shared, it will load it.

By default, blog_id is 1, the master site, and sub sites can always use shared master site snippets

Requires: 3.3.1 or higher
Compatible up to: 4.5.3
Last Updated: 3 months ago
Active Installs: 30,000+

Ratings

4.8 out of 5 stars

Support

4 of 16 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,2,2
100,3,3
100,1,1
100,2,2
100,1,1
100,1,1
100,1,1
86,7,6
100,1,1
100,1,1
100,1,1
100,3,3
100,1,1
50,2,1
100,1,1
67,3,2
50,2,1
50,2,1 100,1,1 100,1,1 100,1,1 0,1,0 0,1,0 50,2,1 100,1,1
0,1,0
100,1,1