“5sec Run PHP” Documentation by “Web factory Ltd” v1.0


“5sec Run PHP” WordPress plugin

Created: 15/02/2011, revision 1
By: Web factory Ltd
Email: info@webfactoryltd.com

Thank you very much for purchasing our WordPress plugin. If you have any questions that are beyond the scope of this help file, please feel free to email us via our user page contact form. Have a good one!


Table of Contents

  1. Online documentation, examples and help
  2. Installation
  3. Examples
  4. Configuration
  5. FAQ
  6. Sources and Credits

B) Installation - top

Installation

  1. Download the plugin ZIP file.
  2. Open your WP admin and go to Plugins -> Add New -> Upload. Browse for the ZIP file 5sec-run-php-plugin.zip on your computer and hit “Install Now”.
  3. Activate the plugin.
  4. You can now write PHP code using the [php] shortcode.

Post install checkup

  1. As the plugin will inform you it's not advisable to use the visual editor while writing PHP code. Disable it in your profile's preferences.
  2. If [php] shortcode is already used by some other plugin you will be notified. Use plugin's settings to configure a different shortcode name, ie: run-php.
  3. By default plugin hides all PHP errors produced by your code so you will not be able to see them. Use plugin's settings to configure error reporting.

Upgrade

  1. Deactivate and delete plugin in your WP admin -> Plugins.
  2. Use the Add New -> Upload function to upload the new ZIP file.
  3. Activate the plugin.

C) Examples - top

Let's output a random number using PHP.

[php]echo 'This is a random number: ' . rand(0, 100) . '.';[/php]

We can also interact with the usual WP objects such as $post.

[php]global $post; echo 'ID of this post is ' . $post->ID . '.';[/php]

By default all PHP errors are hidden but we can easily display them, on a global or per-shortcode basis.

[php errors="show"]echo $test;[/php]

Just want to show off your code? No problem!

[php action="show"]global $wpdb; $time = $wpdb->get_var('SELECT NOW()'); echo 'The time is: ' . $time; [/php]



D) Configuration - top

All options are configured in WP Admin – Settings – 5sec Run PHP or as shortcode parameters.

Option name Description Default
Error Reporting When developing it's useful to show all errors but in production environments please hide all errors. This option can be overwritten on a per-shortcode basis with "errors" parameter. hide all errors, warnings and notices
Action for PHP Code in Content 5sec Run PHP plugin is ment to run PHP code but you can use this aditional functionality to provide security or to show off your code. This option can be overwritten on a per-shortcode basis with "action" parameter. run PHP code
Action for PHP Code in Excerpt See above. run PHP code
Action for PHP Code in Text Widget See above. run PHP code
Action for PHP Code in RSS Content See above. run PHP code
Action for PHP Code in RSS Excerpt See above. run PHP code
Shortcode name Change the shortcode name is another plugin is already using it. Write only the shortcode name, without brackets. php

Using the shortcode

You don't have to write opening and closing PHP tags (<?php ?>) in your code. Just use: [php] //code [/php] If you want to access post data for current post remember to put "global $post" in your code. Same applies to "global $wpdb".

Error reporting is globally defined in options but it's also available on a per-shortcode basis using the "error" parameter. Ie: [php errors="hide"] // some code [/php]. Accepted values: default, show, hide.

Actions are globall defined in options but can also be defined on a per-shortcode basis using the "action" parameter. Ie: [php action="show"] // some code [/php]. Accepted values: run, delete, show, show-plain.

When action is set to "show-plain" the code is outputed in a <span> element with "php-code" class.
When action is set to "show" the code is outputed in a <pre> element with "php-code" class and aditional CSS is included in your site's footer for code styling (please be sure your theme uses wp_footer() function call).


E) FAQ - top

I'm getting some weird PHP errors

It's really hard to say what's causing them but check and double-check your syntax. Do you have all brackets closed? All semi columns in place? Are all the variables you're using in the right scope?

Will this plugin slow my site down?

That completely depends on the code you write. Plugin itself has an absolute minimal footprint when not used. Please don't write miles of code in posts. Write a plugin or use functions.php. It' much better / faster / safer.

Can I interact with WP database via this plugin?

If you're able to write the code - sure. Just remember to make the $wpdb object global using "global $wpdb".

Can I highlight PHP code with this?

No. You can just output formatted code for easier reading.


F) Sources and Credits - top

No external PHP related assets or other copyrighted materials were used in this script's code.


Once again, thank you so much for purchasing this WordPress plugin. As stated at the beginning, we'd be glad to help you if you have any questions relating to this theme. We'll do our best to assist. If you have a more general question relating to the themes on ThemeForest, you might consider visiting the forums and asking your question in the "Item Discussion" section.

Web factory Ltd.

Go To Table of Contents