Provides an interface for developers to easily add PHP code to posts and widgets via selectable shortcodes.
= My Snippets are not showing up!=
Make sure your files use the correct extension. If you have configured the plugin to look for
.snippet.php files, then any
.php files will not be selectable as PHP Snippets.
Make sure you have correctly configured your PHP Snippets directory under Settings --> PHP Snippets. The directory has to be a full path, e.g.
/home/myuser/public_html/snippets or you can use the
[+ABSPATH+] placeholder to point to the web root of your site, e.g.
As of version 0.9, the information header is optional. Using it, however, can enhance the user experience because it lets users know what your Snippet does and you can customize the inputs.
Your Snippets should include an information header in the same way that WordPress plugins and themes, but it's simplified. Include a Description: and a Shortcode: to indicate a description and a sample shortcode, respectively.
/* Description: Generates a link to a post or page based on its ID. Shortcode: [link id=123]Click here[/link] */
Look at the examples in the
php-snippets/snippets directory for some examples.
Anything you pass in your shortcode will be passed to your Snippet. E.g.
[mySnippet x="123" y="Llama"] will make the variables
$y available in your Snippet (they would contain "123" and "Llama", respectively).
$content variable is reserved for when you use a full tag, e.g.
[mySnippet]My content goes here[/mySnippet] would make$content` contain the text "My content goes here".
Warning: WordPress allows only lowercase parameter names, so your input variables should be lowercase.
Your Snippet should print its output (not return it). This makes it easy for you to include reusable bits of HTML.
Technically speaking, your code doesn't have to output anything -- some scripts may only need to execute on the back-end and remain out of site.
Check to make sure the bug is actually in the plugin and not in one of your Snippets. This plugin attempts to act primarily as a transparent pass-through, and the error messages should be confined to your code (hopefully not mine). If there's something goofy going on, please let me know by filing a bug report.
Requires: 3.0 or higher
Compatible up to: 4.1.0
Last Updated: 2015-2-8
Active Installs: 2,000+
1 of 2 support threads in the last two months have been resolved.
Got something to say? Need help?