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
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)
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"
The plugin's snippet editor now has better formatting, and supports AJAX saving for snippet updates (request by eneasgesing)
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)
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!
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.6.0
Last Updated: 3 months ago
Active Installs: 40,000+
0 of 3 support threads in the last two months have been marked resolved.
Got something to say? Need help?