{"id":895,"date":"2012-08-15T12:20:31","date_gmt":"2012-08-15T19:20:31","guid":{"rendered":"https:\/\/2012.portland.wordcamp.org\/?page_id=895"},"modified":"2012-08-15T18:01:44","modified_gmt":"2012-08-16T01:01:44","slug":"dont-put-that-in-functions-php-or-how-to-write-a-basic-plugin","status":"publish","type":"page","link":"https:\/\/portland.wordcamp.org\/2012\/speakers\/dont-put-that-in-functions-php-or-how-to-write-a-basic-plugin\/","title":{"rendered":"Don\u2019t Put That In Functions.php!"},"content":{"rendered":"<p>Or, How to Write A Basic Plugin<\/strong><br \/>\n<em>Kailey Lampert<\/em><\/p>\n<p>You&#8217;re all too familiar with copying all those top-10 latest-and-greatest best-tricks-you&#8217;ve-never-heard-of snippets from various tutorial sites into your theme&#8217;s functions.php file. What could be easier? Copy a few lines of code, just paste it in, and you&#8217;re good-to-go, right?<\/p>\n<p>Wrong!<\/p>\n<p>I&#8217;m not knocking those kinds of posts at all, they often have very handing bits of code, but the functions.php file is in your theme because it&#8217;s for your theme. If your snippets\/code are &#8220;theme-agnostic&#8221; &#8211; adding functionality that should persist regardless of the theme, like custom shortcodes or widgets &#8211; functions.php is the wrong place for it. You&#8217;ll risk losing that functionality if you ever update or switch themes.<\/p>\n<p>So we&#8217;ll start with a simple code snippet, make it work without using functions.php, and step-by-step turn it into a shiny plugin using best-practices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Or, How to Write A Basic Plugin Kailey Lampert You&#8217;re all too familiar with copying all those top-10 latest-and-greatest best-tricks-you&#8217;ve-never-heard-of snippets from various tutorial sites into your theme&#8217;s functions.php file. What could be easier? Copy a few lines of code, &hellip; <a href=\"https:\/\/portland.wordcamp.org\/2012\/speakers\/dont-put-that-in-functions-php-or-how-to-write-a-basic-plugin\/\">Continue reading <span class=\"assistive-text\">Don\u2019t Put That In Functions.php!<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":488108,"featured_media":0,"parent":46,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-895","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/PheX1M-er","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/pages\/895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/users\/488108"}],"replies":[{"embeddable":true,"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/comments?post=895"}],"version-history":[{"count":3,"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/pages\/895\/revisions"}],"predecessor-version":[{"id":932,"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/pages\/895\/revisions\/932"}],"up":[{"embeddable":true,"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/pages\/46"}],"wp:attachment":[{"href":"https:\/\/portland.wordcamp.org\/2012\/wp-json\/wp\/v2\/media?parent=895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}