Wordpress plugins
PHP Snippets

PHP Snippets

Version : 1.2
Tested up to : 4.1.0
Number of download : 28511
Author : Sorry
Average rating : 3 / 5 on 7 votes 7 votes, 3 avg.rating

Screenshots

PHP Snippets
PHP Snippets
PHP Snippets
PHP Snippets

This plugin is officially retired, and it is not recommended for new installs. This plugin allows developers to easily add PHP code to their posts and widgets. All .snippet.php files contained in the configured directory will be executable via a corresponding [shortcode]. For example, a file named my-code.snippet.php can be executed by adding a [my-code] shortcode to your post content. The source directory is configurable: you can put it anywhere on your server that you wish, e.g. you can enhance the security of your code by storing it outside your server’s document root. By keeping all the PHP code in PHP files, you ensure that your WordPress posts and pages remain clean. All available shortcodes are listed when the user clicks a custom TinyMCE button. See the Project Home Page for more information. This plugin requires PHP 5.2.6 or greater. This plugin can save you from writing lots of other plugins because you can easily tie into PHP files without having to register your own plugins. WARNING: this has not been tested on Windows servers. Sorry, but I don’t have access to one, so I’ve been unable to tune the permissions checks. Create PHP Snippets A PHP snippet is any bit of code that you wish to reuse via shortcode. Create a file in one of the directories you defined as a Snippet directory. DO NOT create Snippets inside the wp-content/plugins/php-snippets/ directory! In order to be picked up on the radar, your file must use one of the extensions you defined (e.g. .snippet.php) and you should include a comment block with a “Description” and a “Shortcode” attribute, e.g. /* Description: Generates a link to a post or page based on its ID. Shortcode: [link id=123]Click here[/link] */<h3>Usage</h3> 1. Create a new post or page 1. Click the <?php button in the TinyMCE toolbar to see a list of available PHP Snippets 1. Select the Snippet you want to insert into your post: a shortcode should be generated inside your post content. Optionally, you can manually type in the shortcode and add in any variables you have defined. Widget You can add your snippet output to any Widget by using the PHP Widget. In the WP dashboard, navigate to Appearance –> Widgets Drag the PHP Widget from the list of available widgets to any valid widget area on the right. Add a title for your widget Select one of your PHP Snippets Adjust the shortcode as desired (e.g. to add in special parameters) Save the widget instance.

Download now