This plugin has been closed and is no longer available for download.

Shortcode Exec PHP

Description

Using this plugin you can execute arbitrary PHP code using shortcodes in your posts, pages, comments, widgets and RSS feeds, just like manually defined shortcodes. The shortcodes and associated PHP code are defined using the settings of this plugin. It is possible to parse and use shortcode parameters and to use shortcode content. Defined shortcodes can be deleted and disabled.

Advantages over other solutions:

  1. Your texts do not have to contain PHP code
  2. PHP code can be reused (by reusing the shortcode)
  3. All PHP code is organized at one place
  4. Syntax highlighting
  5. You can test your PHP code before using it
  6. Import/export of shortcode definitions

For those concerned about security (hopefully everybody): only administrators can define shortcodes and associated PHP code (see also the FAQ).

See my other plugins.

Acknowledgments

This plugin uses:

  • EditArea
    by Christophe Dolivet and published under the GNU Lesser General Public License

  • jQuery JavaScript Library published under both the GNU General Public License and MIT License

All licenses are GPL-Compatible Free Software Licenses.

Screenshots

  • Shortcode exec PHP

Installation

Using the WordPress dashboard

  1. Login to your weblog
  2. Go to Plugins
  3. Select Add New
  4. Search for Shortcode Exec PHP
  5. Select Install
  6. Select Install Now
  7. Select Activate Plugin

Manual

  1. Download and unzip the plugin
  2. Upload the entire shortcode-exec-php/ directory to the /wp-content/plugins/ directory
  3. Activate the plugin through the Plugins menu in WordPress

FAQ

Where can I define shortcodes?

WordPress menu Tools > Shortcode Exec PHP

What happens when I disable a shortcode?

The shortcode will not be handled and will appear unprocessed.

Who can access the settings and the PHP code?

Users with manage_options (single user) or manage_network (multi user) capability (administrators).

Who can use the defined shortcodes?

Anyone who can create or modify posts, pages and/or widgets or can write comments.
Shortcode execution in widgets, excerpts, comments and RSS feeds is disabled by default (unless another plugin or your theme does enable it).
It is possible to restrict shortcode execution in posts and pages based on the capabilities of the post or page author (since version 1.18).

How are PHP errors handled?

Because the PHP eval function is used, errors cannot be handled unfortunately, so test your code thoroughly.

How many shortcodes can I define?

Unlimited.

I get a blank page when I use a shortcode on a large post/page

This can happen if the PCRE backtrack value is too low. Try increasing it using the plugin settings.

Where are the shortcode definitions stored?

The shortcode name, options and PHP code are stored as WordPress options.

How can I change the styling of the settings?
  1. Copy shortcode-exec-php.css to your upload directory to prevent it from being overwritten by an update
  2. Change the style sheet to your wishes; the style sheet contains documentation
How do I test a shortcode with parameters?

Indirectly, by using default values.

Should I use PHP opening and closing tags?

No, omit both <?php and ?>.

Can I embed HTML code?

Yes, if you enclose the HTML code with ?> and <?.

My shortcode appears with a question mark behind it

The post or page author has insufficient privileges to execute shortcodes.

I get ‘Warning: … in … : eval()’d code on line xxx’

This means there is an error in your shortcode definition on line xxx.

My code doesn’t work!

Note that your code is not directly executed in the WordPress environment, but in a function.
This means for example that a global $wpdb; is needed to access the database class.

Where can I ask questions, report bugs and request features?

This plugin is not supported anymore

Reviews

Read all 38 reviews

Contributors & Developers

“Shortcode Exec PHP” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Shortcode Exec PHP” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

Development version

  • You can download the development version here

1.52

  • Fixed inserting shortcode

1.51

  • Made pro feature free

1.50

  • Tested with WordPress 3.8.1

1.49

  • Tested with WordPress 3.8

1.48

  • Tested with WordPress 3.7.x

1.47

  • Fixed a PHP warning

1.46

  • Updated SimpleModal to version 1.4.4
  • Added clarification
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.45

  • Added Slovak (sk_SK) translation

1.44

  • Bugfix: html entities (by Joe Pruett, thanks!)
  • Added Lithuanian (lt_LT) by Host1Free

1.43

  • Bugfix: added missing file

1.42

1.41

  • Bugfix: require manage_options capability when site activated on a multisite network
  • Note: PHP4 support will be dropped from the next release

1.39

  • Bugfix: require manage_options capability when site activated on a multisite network

1.38

  • New feature: option to disable wpautop
  • Updated support page
  • Updated Chinese (zh_CN) translation by Jie
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations
  • Updated Norwegian (nb_NO) translation by Stein Ivar Johnsen

1.37

1.36

  • Bugfix: PHP 4 compatibility

1.35

  • Bugfix: no EditArea on network sites

1.34

  • New feature: import/export (requires SimpleXML)
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations
  • Updated Norwegian (nb_NO) translation by Stein Ivar Johnsen
  • Tested with WordPress 3.3

1.33

  • Improvement: removed dependency on PLUGINDIR
  • Changed to minimum WordPress version 3.1
  • Updated Norwegian (nb_NO) translation by Stein Ivar Johnsen

1.32

  • Added Sustainable Plugins Sponsorship Network again
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.31

  • Removed Sustainable Plugins Sponsorship Network

1.30

  • Bugfix: solved a few warnings

1.29

  • Bugfix: jQuery compatibility WordPress version 3.2

1.28

  • Improvement: added title to description field
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.27

  • Improvement: added description field for TinyMCE

1.26

  • Bugfix: remove old shortcode definition when renaming
  • Bugfix: added stripslashes for shortcode name
  • Improvement: better example

1.25

  • Bugfix: menu when network activated

1.24

  • Bugfix: suppressing PHP warnings if ini_set disabled
  • Improvement: fixed some PHP notices
  • Improvement: trimming text input

1.23

1.22

  • Bugfix: compatibility with PHP 4

1.21

  • Bugfix: make sure required capability for authors is set
  • Fixed some PHP warnings

1.20

  • Bugfix: support for WordPress 3.1, tested and working now

1.19

  • Support for WordPress 3.1 network of sites (multisite)

1.18

  • Enhancement: case insensitive sorting of shortcodes
  • Better compatiblity with other TinyMCE buttons
  • New feature: shortcuts for jumping to shortcode definitions
  • New feature: required capability for authors to use shortcodes, see FAQ
  • Bugfix: shortcode processing in RSS feeds can be turned off now
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations
  • More donate buttons …

1.17

  • Bugfix: made EditArea working on tools page
  • Bugfix: display toggle editor for new shortcode when not displaying initially
  • Bugfix: no scroll to top when enabling editor for new shortcode the first time
  • Extra security check for TinyMCE editor shortcode button popup
  • New feature: display last used shortcode attributes
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.16

  • Added option to select required capability for TinyMCE button
  • Added tools menu entry for non-network sites
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.15

  • TinyMCE editor button by default disabled for security reasons
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.14

  • New feature: TinyMCE editor insert shortcode button
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations
  • Tested with WordPress version 3.1 RC 3

1.13

  • Added option to turn off code editor initially
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations
  • Fixed JavaScript error: initializing code editor on options page only
  • Tested with WordPress version 3.1 beta 1

1.12

  • Added separators between shortcode definitions
  • Fixed index after deleting shortcodes

1.11

  • Added option to make shortcodes global for multi user sites
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.10

  • Support for multi user sites

1.9

  • Replaced ajax gets by posts

1.8

  • Using default PCRE configuration as minimum

1.7

  • Buffer output by default for new shortcodes
  • Minimum value of 100,000 for PCRE configurations

1.6.1

  • Added Farsi (fa_IR) translation by Hamid

1.6

  • Added options to configure PCRE

1.5

  • Using https transport when needed

1.4

  • ‘I have donated’ removes donate button

1.3.1

  • Added an option to disable html entitiy encoding
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.3

  • Removed decoding/encoding of html entities

1.2.2

  • Added option to store css in upload folder

1.2.1

  • Constructor compatibility with PHP 5.3.3+

1.2

  • Added option to handle echoed output
  • Updated Dutch (nl_NL) and Flemish (nl_BE) translations

1.1

  • Using character encoding of menu Settings > Reading, normally UTF-8.

1.0

  • Added Dutch (nl_NL) and Flemish (nl_BE) translations
  • No complaints so far, updating to version 1.0

0.6

  • Added Revert button, which will undo unsaved/untested changes
  • Better error handling

0.5

  • Scrolling to top after loading EditArea´s
  • Disabling EditArea´s on test, save, etc.

0.4.1

  • More compatible ajax handling

0.4

  • Syntax highlighting
  • In-place add, update and delete of shortcodes (using AJAX)
  • Shortcodes can be tested in the administration backend

0.3

  • Only administrators can see options and shortcode definitions now
  • Shortcodes are sorted alphabetically in the administration backend

0.2

  • Added options to enable shortcodes in excerps, comments and RSS feeds
  • Added options to change width and height of PHP code textarea
  • Improved layout of options

0.1

  • Initial version

0.0

  • Development version