{"id":443,"date":"2012-10-18T14:00:28","date_gmt":"2012-10-18T12:00:28","guid":{"rendered":"https:\/\/wprealm.com\/?p=443"},"modified":"2012-10-18T14:00:28","modified_gmt":"2012-10-18T12:00:28","slug":"the-ten-commandments-of-wordpress-development","status":"publish","type":"post","link":"http:\/\/wprealm.local\/the-ten-commandments-of-wordpress-development\/","title":{"rendered":"The Ten Commandments of WordPress Development"},"content":{"rendered":"

About a year ago I made an inventory of all the WordPress websites I created together with my colleagues over the past few years. I found out that we used a lot of different approaches. It lacked standardization. What we needed was a uniform approach to development and, of course, a philosophy. At first I was a little flabbergasted, I really did not know where to start. Of course we all knew about the Codex, the forums and tutorial websites, but we did not have any contact with the WordPress community at all<\/em>.<\/p>\n

This was something that needed to change. We decided to hire a local WordPress expert and invited him to give us some advice with respect to this matter \u2013 our expert came from Friesland<\/a>. Do you feel yourself situated in the same position as I was one year ago? Then this might be your starting point too. WordPress is used all over the world. So you are bound to find an expert near you.\u00a0 Good places to start searching are WordPress forums in your own language, WP Meetups and amongst WordCamp organizers.<\/p>\n

I received a lot of tips and pointers to start my standardizing approach. I immediately started to draft a list of focus points, in fact a list of the most pressing points at that very moment. I chose to limit my list to ten focus points for me and my colleagues to work on and I called them: \u201cThe Ten Commandments\u201d.\u00a0 A short list, that is what I wanted, as well as a constantly evolving list of points, , raising the bar as we went along.<\/p>\n

My first version of the Ten Commandments featured items like: \u201cEnqueue your scripts correctly\u201d and \u201cOnly use one stylesheet, and use the right one\u201d. Nowadays I don’t feel I have to remind myself and my colleagues about these items, so other items were added to my list. A month ago I reworked the original list into a new one with new, more general, focal points. I wrote them down on a big whiteboard in our office, no developer can miss it. Here they are, my current ten commandments:<\/p>\n

1. Always set WP_DEBUG to true during development<\/h3>\n

You would not believe how many plugins and themes, and how much custom code triggers notices and warnings. All these low level errors can cause memory leakage, causing your site to consume more memory than needed. WP_DEBUG is also a useful tool to find out if you are using any deprecated functionality.<\/p>\n

2. Adhere to WordPress Coding & CSS-standards<\/h3>\n

Our expert, Remkus, also wrote a post about this some year ago<\/a>. Wouldn\u2019t it be nice if we all wrote our code as shown in the WordPress Coding Standards<\/a>?\u00a0The standards, as set by WordPress core developers, are the cumulation of years of experience. Adhering to these rules leaves you with a clean readable code other people would love to read to. There is a reason for the motto \u2018code is poetry\u2019.<\/p>\n

3. Comment your code<\/h3>\n

Your code should not only be easily readable by others, but others should also be able to understand why you chose to write a bit of code in a certain manner. There are many ways to skin a cat, explain to your co-workers why<\/em> you wrote it like that. There are documentation guidelines in the Codex<\/a>.<\/p>\n

4. Learn how the core works, read the actual lines of code<\/h3>\n

You should know how WordPress works internally. When are (mu)plugins loaded? When are database queries being performed, when are theme files loaded and so on? There is a great deal you can learn from reading the core. It\u2019s inspiring!<\/p>\n

5. Use WordPress internal functions and APIs whenever you can<\/h3>\n

I have written a lot of code in the past that could easily be substituted with a function or procedure that is already embedded in the core. If only I knew it was there\u2026 Browse through the core files (as stated in my previous commandment) and figure out how these all work. You will be amazed with what you can find in there. Like these utility functions<\/a>.<\/p>\n

6. Namespace your code<\/h3>\n

A lot of people write code for WordPress in themes and plugins. Chances are that your function name, or class of variable is the same as someone elses.\u00a0 You should always namespace it. I use my inititals FPL, like: fpl_functioname();<\/code><\/p>\n

7. Never trust user input!\u00a0Sanitise\u00a0& escape!<\/h3>\n

This remains a really important issue. Today and most probably forever. WordPress is loaded with tools enabling you to write secure sites. The best read for this is chapter 6 of this book<\/a>. You do own that book, right?<\/p>\n

8. Use nonces<\/h3>\n

This is an extension of my previous commandment. Using nonces secures all the functionality your forms need. Check out this page in the Codex<\/a>;\u00a0using nonces makes sense!<\/p>\n

9. Internationalize your code<\/h3>\n

Living in Europe, we are used to talking and writing a lot in different languages.\u00a0 Don’t be surprised when your client requests his plugin or theme be available in other languages or even dialects, either now or in the future. Do you write your code with localization in mind? That’s makes your task of adding another language easier in future. WPtuts has a nice tutorial about localization for themes and plugins<\/a>.<\/p>\n

10. Performance, performance, performance<\/h3>\n

We are building high-performance-sites. With everything that you write or include, be it a database query, PHP code, HTML, CSS, JavaScript or assets like images, you always should keep performance in mind. Simply each and every nanosecond counts.<\/p>\n

Illustration by Sjors Trimbach <\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"

About a year ago I made an inventory of all the WordPress websites I created together with my colleagues over the past few years. I found out that we used a lot of different approaches. It lacked standardization. What we needed was a uniform approach to development and, of course, a philosophy. At first I […]<\/p>\n","protected":false},"author":11,"featured_media":490,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[4],"tags":[25,133],"people":[],"company":[],"events":[],"acf":[],"yoast_head":"\nThe Ten Commandments of WordPress Development - WP Realm<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Ten Commandments of WordPress Development\" \/>\n<meta property=\"og:description\" content=\"About a year ago I made an inventory of all the WordPress websites I created together with my colleagues over the past few years. I found out that we used a lot of different approaches. It lacked standardization. What we needed was a uniform approach to development and, of course, a philosophy. At first I […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Realm\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wprealm\" \/>\n<meta property=\"article:published_time\" content=\"2012-10-18T12:00:28+00:00\" \/>\n<meta name=\"author\" content=\"Floris Lof\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@__jester\" \/>\n<meta name=\"twitter:site\" content=\"@wprealm\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Floris Lof\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/\",\"url\":\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/\",\"name\":\"The Ten Commandments of WordPress Development - WP Realm\",\"isPartOf\":{\"@id\":\"https:\/\/wprealm.com\/#website\"},\"datePublished\":\"2012-10-18T12:00:28+00:00\",\"dateModified\":\"2012-10-18T12:00:28+00:00\",\"author\":{\"@id\":\"https:\/\/wprealm.com\/#\/schema\/person\/afb34d0bc82be31f660ca5ebd4426438\"},\"breadcrumb\":{\"@id\":\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wprealm.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Ten Commandments of WordPress Development\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wprealm.com\/#website\",\"url\":\"https:\/\/wprealm.com\/\",\"name\":\"WP Realm\",\"description\":\"WordPress news, community news, reviews and more from all over the world\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wprealm.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wprealm.com\/#\/schema\/person\/afb34d0bc82be31f660ca5ebd4426438\",\"name\":\"Floris Lof\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wprealm.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/22a5095f08d4ec8d9ac2ef66d0de01e1?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/22a5095f08d4ec8d9ac2ef66d0de01e1?s=96&d=mm&r=g\",\"caption\":\"Floris Lof\"},\"description\":\"Floris believes all code should be written while listening to the pounding beats of heavy metal for the best result. His spare time is consumed by his family, watching a lot of movies and barbecuing.\",\"sameAs\":[\"http:\/\/florisplof.nl\",\"https:\/\/twitter.com\/__jester\"],\"url\":\"http:\/\/wprealm.local\/author\/floris\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"The Ten Commandments of WordPress Development - WP Realm","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/","og_locale":"en_US","og_type":"article","og_title":"The Ten Commandments of WordPress Development","og_description":"About a year ago I made an inventory of all the WordPress websites I created together with my colleagues over the past few years. I found out that we used a lot of different approaches. It lacked standardization. What we needed was a uniform approach to development and, of course, a philosophy. At first I […]","og_url":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/","og_site_name":"WP Realm","article_publisher":"https:\/\/www.facebook.com\/wprealm","article_published_time":"2012-10-18T12:00:28+00:00","author":"Floris Lof","twitter_card":"summary_large_image","twitter_creator":"@__jester","twitter_site":"@wprealm","twitter_misc":{"Written by":"Floris Lof","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/","url":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/","name":"The Ten Commandments of WordPress Development - WP Realm","isPartOf":{"@id":"https:\/\/wprealm.com\/#website"},"datePublished":"2012-10-18T12:00:28+00:00","dateModified":"2012-10-18T12:00:28+00:00","author":{"@id":"https:\/\/wprealm.com\/#\/schema\/person\/afb34d0bc82be31f660ca5ebd4426438"},"breadcrumb":{"@id":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wprealm.com\/the-ten-commandments-of-wordpress-development\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wprealm.com\/"},{"@type":"ListItem","position":2,"name":"The Ten Commandments of WordPress Development"}]},{"@type":"WebSite","@id":"https:\/\/wprealm.com\/#website","url":"https:\/\/wprealm.com\/","name":"WP Realm","description":"WordPress news, community news, reviews and more from all over the world","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wprealm.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wprealm.com\/#\/schema\/person\/afb34d0bc82be31f660ca5ebd4426438","name":"Floris Lof","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wprealm.com\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/22a5095f08d4ec8d9ac2ef66d0de01e1?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/22a5095f08d4ec8d9ac2ef66d0de01e1?s=96&d=mm&r=g","caption":"Floris Lof"},"description":"Floris believes all code should be written while listening to the pounding beats of heavy metal for the best result. His spare time is consumed by his family, watching a lot of movies and barbecuing.","sameAs":["http:\/\/florisplof.nl","https:\/\/twitter.com\/__jester"],"url":"http:\/\/wprealm.local\/author\/floris\/"}]}},"_links":{"self":[{"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/posts\/443"}],"collection":[{"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/comments?post=443"}],"version-history":[{"count":0,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/posts\/443\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/"}],"wp:attachment":[{"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/tags?post=443"},{"taxonomy":"people","embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/people?post=443"},{"taxonomy":"company","embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/company?post=443"},{"taxonomy":"events","embeddable":true,"href":"http:\/\/wprealm.local\/wp-json\/wp\/v2\/events?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}