runPHP Manual

Installation Instructions

  • Download the latest version
  • Unzip the contents (the entire runPHP directory) into /wp-content/plugins/
  • In Options > Writing
    • Turn off “WordPress should correct invalidly nested XHTML automatically”
    • Do not use this with the visual rich editor
  • Visit the “Options > runPHP” page to set who can use the plugin (default is Administrators)
  • Create a post and check the “run PHP code?” checkbox to enable PHP code to be dropped in to your post - this must be set on a per-post basis.
  • I10n support is available only if WP_LANG is defined in your wp-config.php file.
    (English, French, and German are included. You can use POEdit to contribute your own.)

Usage

Caveats and Gotchas

  • Code executed by runPHP is not in the global scope. It is executed as if it were inside a function block and so you’ll need to declare your globals accordingly. (This is a limitation of PHP’s eval() function, not the plugin itself.)
  • I have tested this with PHP Markdown and may be relying on some of its textflow in parsing a post’s content.
  • The 1.x version does not have a submenu in Options - every user can use PHP. To turn it on, check the “eval() code” box in the Advanced post editing page. (It does not show up in the Basic editing page!)
  • Some people have reported seeing an error message of “unexpected T_OBJECT_OPERATOR” in the runPHP_options_ui.inc.php file. I think this is because of how PHP4 handles objects - will you add a comment (preferably in this forum thread) about what version of PHP your website is using?
  • (from x24all.nl) - With few badly written WordPress themes, the plugin does not work. This is likely caused by a missing wp_head() call in the theme’s header template (often called header.php). If that is the case, fixing it is simply a matter of inserting
<?php wp_head(); ?>

at the right point in the php template. See WP Themes and Microsummary plugin for more details.

Understanding User Roles

By default, no one other than Admins have the can_runPHP capability. An Administrator grants the capability to Roles via the Options > runPHP page.

Users with Manage Options or can_runPHP capabilities can also set whether they want to use runPHP in their profile’s personal options section.

A user’s personal options will override their Role’s options.

In practice, this means that Administrators (the only group with default permission to Manage Options) can set the runPHP ability for Roles and for individual users. Non-administrators granted runPHP privileges may individually select to opt out of using runPHP, but cannot opt back in (unless they also have the Manage Options capability).

I highly recommend getting the Role Manager plug-in for an addition way to manage your Roles’ permissions.

Future Changes

Your feedback will help direct where I spend my time

  • Possibility of making the runPHP box draggable and closeable, like the rest of the dbx boxes.
  • Support for WordPress 2.0 user roles Done!
  • Hiding of PHP code when a post is edited by someone who does not have permission to use the runPHP plugin - this may be too hard, since I’ll have no way of determining where to inject the PHP code back into the post
  • Better integration / work-around with the new visual rich editor (tinyMCE)

Back to the main runPHP page.