{"id":1681,"date":"2014-12-03T22:24:13","date_gmt":"2014-12-03T21:24:13","guid":{"rendered":"https:\/\/plainviewplugins.com\/?page_id=1681"},"modified":"2015-12-21T21:14:46","modified_gmt":"2015-12-21T20:14:46","slug":"getting-started","status":"publish","type":"page","link":"https:\/\/plainviewplugins.com\/sdk\/getting-started\/","title":{"rendered":"Getting started"},"content":{"rendered":"<p>This page assumes that you have cloned the WordPress plugin SVN structure (assets, tags, trunk) and are ready to begin installing the SDK in the <em>trunk<\/em> directory.<\/p>\n<p>Installation is done in the following steps:<\/p>\n<ol>\n<li>Download the SDK into a source directory<\/li>\n<li>Rename the SDK namespace<\/li>\n<li>Add the SDK namespace into your Composer<\/li>\n<\/ol>\n<h2>1. Download the SDK into a source directory<\/h2>\n<p>Good coding practise says we should keep our code in a separate directory. Let&#8217;s say <code>src\/<\/code><\/p>\n<p><code>git clone https:\/\/bitbucket.org\/edward_electric\/plainview-sdk.git<\/code><\/p>\n<p>In <code>src\/sdk<\/code> you should now have the files <code>base.php<\/code>, <code>composer.json<\/code>, and the directory <code>wordpress<\/code>, amongst others. Download is complete.<\/p>\n<h2>2. Rename the SDK namespace (optional, but a good idea)<\/h2>\n<p>The SDK has the namespace <code>plainview\\sdk<\/code>. This is fine, but if you plan to release your plugin it could be installed together with another plugin that uses the Plainview SDK. Class autoloading will load one of the SDK&#8217;s, and there is no knowing whether it will be your or the other plugin&#8217;s version. This is a conflict that must be avoided by renaming your SDK namespace.<\/p>\n<p>In the <code>scripts\/<\/code> directory you will find a script called <code>sdk_rename.sh<\/code>. This file runs a search and replace using Perl to rename the namespace to something more unique.<\/p>\n<p><code>.\/rename_sdk.sh SUFFIX<\/code><\/p>\n<p>This will rename all of the namespaces in the SDK to <code>plainview\\sdk<em>SUFFIX<\/em><\/code>. Your plugin should now use this namespace instead of the default.<\/p>\n<h2>3. Add the SDK namespace into your Composer (also optional)<\/h2>\n<p>Using Composer for its class autoloading is a good idea. Add the SDK&#8217;s customized namespace into your <code>composer.json<\/code>. Here is the autoload portion of <a title=\"ThreeWP Broadcast\" href=\"https:\/\/plainviewplugins.com\/threewp-broadcast\/\">ThreeWP Broadcast&#8217;s<\/a> composer.json.<\/p>\n<pre><code>\"autoload\":\r\n{\r\n\t\"psr-4\":\r\n\t{\r\n\t\t\"threewp_broadcast\\\\\": \"src\/\",\r\n\t\t\"plainview\\\\sdk_broadcast\\\\\": \"src\/sdk\/\"\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>Run <code>composer dump<\/code> and the SDK should now be autoloaded in your plugin!<\/p>\n<h2>Updating the SDK<\/h2>\n<p>If you wish to update the SDK, either due to new features or perhaps a bug being fixed, go to the scripts directory and run<\/p>\n<p><code>.\/sdk_update.sh<br \/>\n<\/code><\/p>\n<p>This will restore the SDK to its original state, download the newest version via Git, and then rename the namespace again.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Explains how to install and prepare the SDK for use in your plugin.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1676,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1681","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/1681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/comments?post=1681"}],"version-history":[{"count":8,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/1681\/revisions"}],"predecessor-version":[{"id":1684,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/1681\/revisions\/1684"}],"up":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/1676"}],"wp:attachment":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/media?parent=1681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}