{"id":15498,"date":"2011-12-03T21:03:29","date_gmt":"2011-12-03T21:03:29","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/php-snippets\/"},"modified":"2016-03-07T02:48:08","modified_gmt":"2016-03-07T02:48:08","slug":"php-snippets","status":"closed","type":"plugin","link":"https:\/\/ar.wordpress.org\/plugins\/php-snippets\/","author":6594301,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.2","stable_tag":"1.2","tested":"4.1.0","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"PHP Snippets","header_author":"Sorry","header_description":"","assets_banners_color":"","last_updated":"2016-03-07 02:48:08","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.nrdc.org\/donate\/","header_plugin_uri":"http:\/\/code.google.com\/p\/wordpress-php-snippets\/","header_author_uri":"https:\/\/www.random.org\/","rating":3.3,"author_block_rating":0,"active_installs":300,"downloads":30488,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.2":"<p>Please upgrade to this version: license checking is removed, and this plugin is officially retired.<\/p>","1.1":"<p>All users should update to this version: it has several new features and improved license checking.<\/p>","1.0":"<p>This is a big update: it includes support for fully customizable paths and file-extensions, improved error checking, and many other improvements.  To run this version, you must get get a license key.  You can pay what you want for the license key, including free, so don&#039;t miss out on the upgrades!  This version requires PHP version 5.3.0 or greater.<\/p>","0.8":"<p>Improved permissions checking in Windows environments.  General fixes.<\/p>","0.7":"<p>Improved checking of file permissions.<\/p>"},"ratings":{"1":"3","2":0,"3":0,"4":0,"5":"4"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.6","0.7","0.8","0.9","1.0","1.1","1.1.1","1.2"],"block_files":[],"assets_screenshots":{"screenshot-2.jpg":{"filename":"screenshot-2.jpg","revision":"1567253","resolution":"2","location":"plugin"},"screenshot-1.jpg":{"filename":"screenshot-1.jpg","revision":"1567253","resolution":"1","location":"plugin"}},"screenshots":{"1":"Use the TinyMCE button to launch the \"Snippet Selector\" in a thickbox.","2":"Select any of the listed PHP Snippets to have its sample shortcode inserted into your post"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1214,28013,662,9309],"plugin_category":[],"plugin_contributors":[80419],"plugin_business_model":[],"class_list":["post-15498","plugin","type-plugin","status-closed","hentry","plugin_tags-code","plugin_tags-exec","plugin_tags-php","plugin_tags-snippet","plugin_contributors-abandoned"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/php-snippets.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/php-snippets\/trunk\/screenshot-1.jpg?rev=1567253","caption":"Use the TinyMCE button to launch the \"Snippet Selector\" in a thickbox."},{"src":"https:\/\/ps.w.org\/php-snippets\/trunk\/screenshot-2.jpg?rev=1567253","caption":"Select any of the listed PHP Snippets to have its sample shortcode inserted into your post"}],"raw_content":"<!--section=description-->\n<p>This plugin is officially retired, and it is not recommended for new installs.<\/p>\n\n<p>This plugin allows developers to easily add PHP code to their posts and widgets.  All <em>.snippet.php<\/em> files contained in the configured directory will be executable via a corresponding [shortcode].  For example, a file named <em>my-code.snippet.php<\/em> 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 <em>outside<\/em> your server's document root.<\/p>\n\n<p>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.<\/p>\n\n<p>See the <a href=\"http:\/\/code.google.com\/p\/wordpress-php-snippets\/\">Project Home Page<\/a> for more information.  This plugin requires PHP 5.2.6 or greater.<\/p>\n\n<p>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.<\/p>\n\n<p>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.<\/p>\n\n<h3>Create PHP Snippets<\/h3>\n\n<p>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.  <em>DO NOT<\/em> create Snippets inside the <code>wp-content\/plugins\/php-snippets\/<\/code> directory!<\/p>\n\n<p>In order to be picked up on the radar, your file must use one of the extensions you defined (e.g. <code>.snippet.php<\/code>) and you should include a comment block with a \"Description\" and a \"Shortcode\" attribute, e.g.<\/p>\n\n<pre><code>\/*\nDescription: Generates a link to a post or page based on its ID.\nShortcode: [link id=123]Click here[\/link]\n*\/&lt;h3&gt;Usage&lt;\/h3&gt;\n<\/code><\/pre>\n\n<p>1. Create a new post or page\n1. Click the <code>&lt;?php<\/code> button in the TinyMCE toolbar to see a list of available PHP Snippets\n1. Select the Snippet you want to insert into your post: a shortcode should be generated inside your post content.<\/p>\n\n<p>Optionally, you can manually type in the shortcode and add in any variables you have defined.<\/p>\n\n<h3>Widget<\/h3>\n\n<p>You can add your snippet output to any Widget by using the PHP Widget.<\/p>\n\n<ol>\n<li>In the WP dashboard, navigate to Appearance --&gt; Widgets<\/li>\n<li>Drag the PHP Widget from the list of available widgets to any valid widget area on the right.<\/li>\n<li>Add a title for your widget<\/li>\n<li>Select one of your PHP Snippets<\/li>\n<li>Adjust the shortcode as desired (e.g. to add in special parameters)<\/li>\n<li>Save the widget instance.<\/li>\n<\/ol>\n\n<!--section=installation-->\n<p>You can install this plugin in the standard way from the WordPress plugin admin screen, or you can download its files and upload the <code>php-snippets<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory.<\/p>\n\n<ol>\n<li>Upload the <code>php-snippets<\/code> directory to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Define one or more Snippet directories where you will save your custom PHP Snippets, e.g. [+ABSPATH+]\/snippets\/<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>My Snippets are not showing up!<\/dt>\n<dd><p>Make sure your files use the correct extension.  If you have configured the plugin to look for <code>.snippet.php<\/code> files, then any <code>.php<\/code> files will not be selectable as PHP Snippets.<\/p>\n\n<p>Make sure you have correctly configured your PHP Snippets directory under <em>Settings --&gt; PHP Snippets<\/em>.  The directory has to be a <em>full<\/em> path, e.g. <code>\/home\/myuser\/public_html\/snippets<\/code> or you can use the <code>[+ABSPATH+]<\/code> placeholder to point to the web root of your site, e.g. <code>[+ABSPATH+]mysnippets<\/code><\/p><\/dd>\n<dt>What information needs to be in the Snippet header?<\/dt>\n<dd><p>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.<\/p>\n\n<p>Your Snippets should include an information header in the same way that WordPress plugins and themes, but it's simplified.  Include a <em>Description:<\/em> and a <em>Shortcode:<\/em> to indicate a description and a sample shortcode, respectively.<\/p>\n\n<pre><code>\/*\nDescription: Generates a link to a post or page based on its ID.\nShortcode: [link id=123]Click here[\/link]\n*\/\n<\/code><\/pre>\n\n<p>Look at the examples in the <code>php-snippets\/snippets<\/code> directory for some examples.<\/p><\/dd>\n<dt>What inputs does my Snippet accept?<\/dt>\n<dd><p>Anything you pass in your shortcode will be passed to your Snippet. E.g. <code>[mySnippet x=\"123\" y=\"Llama\"]<\/code> will make the variables <code>$x<\/code> and <code>$y<\/code> available in your Snippet (they would contain \"123\" and \"Llama\", respectively).<\/p>\n\n<p>The <code>$content<\/code> variable is reserved for when you use a <em>full<\/em> tag, e.g. <code>[mySnippet]My content goes here[\/mySnippet] would make<\/code>$content` contain the text \"My content goes here\".<\/p>\n\n<p>Warning: WordPress allows <em>only<\/em> lowercase parameter names, so your input variables should be lowercase.<\/p><\/dd>\n<dt>What should my Snippet output?<\/dt>\n<dd><p>Your Snippet should <em>print<\/em> its output (not <em>return<\/em> it).  This makes it easy for you to include reusable bits of HTML.<\/p>\n\n<p>Technically speaking, your code doesn't <em>have<\/em> to output anything -- some scripts may only need to execute on the back-end and remain out of site.<\/p><\/dd>\n<dt>There's a Bug in the Plugin!<\/dt>\n<dd><p>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 <em>your<\/em> code (hopefully not mine).  The plugin is no longer maintained, so if there is a bug in the code, you'll have to find a way to fix it yourself.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.2<\/h4>\n\n<p>Retirement notice.  Thank you to everyone who contributed to this plugin, but it is now officially retired.  Licensing is disabled with this version.<\/p>\n\n<h4>1.1<\/h4>\n\n<p>Includes handy features:<\/p>\n\n<ul>\n<li>Ability to show\/hide the TinyMCE button<\/li>\n<li>\"PHP Snippets\" button now visible in plain-text view<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>PHP 5.3.0 is now required.<\/li>\n<li>Configurable suffix, so now your snippets need not use the '.snippet.php' extension.<\/li>\n<li>Pay-what-you-like licensing added. <\/li>\n<li>Various bug fixes and improvements<\/li>\n<\/ul>\n\n<h4>0.8<\/h4>\n\n<ul>\n<li>Improved permissions checking in Windows environments.<\/li>\n<li>General cleanup.<\/li>\n<\/ul>\n\n<h4>0.7<\/h4>\n\n<p>More thorough permissions checking of the configured directories, added some snippets.<\/p>\n\n<h4>0.6<\/h4>\n\n<p>Worked out some bugs, cleaned this thing up for the prom.<\/p>\n\n<h4>0.5<\/h4>\n\n<ul>\n<li>Initial release<\/li>\n<\/ul>","raw_excerpt":"Provides an interface for developers to easily add PHP code to posts and widgets via selectable shortcodes.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/15498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=15498"}],"author":[{"embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/fireproofsocks"}],"wp:attachment":[{"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=15498"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=15498"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=15498"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=15498"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=15498"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/ar.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=15498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}