This plugin lets you execute dynamic PHP code in posts. It masks PHP code before balanceTags, and unmask them afterwards, so it should be safe to use PHP code that has literal HTML tags in it, for example: code which print out HTML.
WordPress 1.5. Version 1.2 is not supported. You will also need PHP version 4.3.0 or later.
Do **NOT** use this plugin if you can’t trust people who make posts in your WordPress installation, it is a **HUGE** security hole. User level is now supported! By default the plugin only operates on level 9 user.
1. Download the plugin: [phpexec.txt](https://priyadi.net/wp-content/plugins/phpexec.txt)
2. Rename the plugin to phpexec.php and put it into your `wp-content/plugins` directory
3. Activate the plugin from WordPress administration menu
In posts, enclose any PHP code you want to execute with <phpcode> … </phpcode>.
Only real PHP code allowed, no <?php … ?> blocks allowed. The block will then be replaced by the output of PHP code. In <phpcode> blocks, you will need to start any PHP command with <?php and end it with ?> as usual.
From the WordPress admin menu, you can change minimum user level that is allowed to use the plugin. It is available from Options – PHPExec menu.
Output of the above code:
This plugin is inspired by [RunPHP](http://mark.scottishclimbs.com/archives/2004/07/02/running-php-in-wordpress-posts/), another plugin which accomplishes the same thing but did not work for me. Thanks to [iang](http://fajran.net/) for tricks to make embedded PHP code feels more like a real PHP code. Some code are borrowed from WordPress source code. Thanks to [Beau Collins](http://beaucollins.com/) for the user level code.
* First public release
* **Non backward compatible change**: now you need to enclose PHP code with <?php … ?> as you would do in real PHP script.
* Added filters to handle excerpts.
* Fixed a small error in evaled code, thanks to [AJ](http://s89631316.onlinehome.us/) for spotting this.
* Added user level security feature.
* Try to avoid using common variable names (thanks to David H. Brown)
* Removing debugging comments should fix the problem with automatic tag insertion done by WordPress.