SlideShare a Scribd company logo
1 of 30
Where to Find Me
•brian@upthemes.com
•Twitter: brianfegter
•github: inspectorfegter
•The Interwebz: coderrr.com
About Me
•Live near Orlando, Florida
  (Titusville = the booming metropolis)
•Hobbies: photography, fountain
  pens, planking (not)
•I work for UpThemes.com and
  LiftUX.com as a lead developer
•Favorite vegetable: popcorn
The Anatomy of a
  Commercial
   Wordpress
     Theme

 A Developmental Overview
The TRUTH about
 commercial themes...

•There is not a single theme that does
  not require support. You must build
  a support system.
•Rarely does a purchased theme
  remain in its original condition.
•A strong percentage of buyers are
  international.
Ground Zero

           SOLID
           Template
          Architecture

http://codex.wordpress.org/Theme_Development
On your mark, get set...STOP


  Understand Template
      Hierarchy


 http://codex.wordpress.org/Template_Hierarchy
Hierarchy Diagram




http://codex.wordpress.org/Template_Hierarchy
Template Structure
       CREDO
            I pledge to:
•Follow template hierarchy patterns
•Clearly name my supporting files/folders
•Never, never, ever, NEVER, ever nest a
  plugin inside my theme
•Clarity over cleverness
Using Wordpress Assets
 •Clearly name your sidebars
 •Use custom post types only when
   necessary

 •Define theme locations for menus
 •Localize your strings - __() _e() are your
   friends

 •Set WP image sizes vs. image resizing
   scripts (TimThumb, etc...)

 •Leverage the power of CSS with
   body_class() and post_class()
To use or
not to use
 Theme
Options...
Our Options Framework




github.com/chriswallace/UpThemes-Framework
Painless Option Creation
Bodacious Functionality
Stupid-Easy
   Implementation

•Include one file in functions.php
  require_once(‘admin/admin.php’);
•Call global $up_options;
•Retrieve your option value by ID
  $up_options->my_awesome_id
Theme Options
     User Health Alert!

•Too many options kill brain cells and
  raise blood pressure.
•No options make users MAD and
  could lead to permanent psychosis.
•Obscure options cause road rage and
  have been linked to chronic multiple-
  punctuationitis!!!!!!!!!!!!!
Code is Poetry
•Code is Narrative.
•Your theme tells a story and has an
  intended plot, characters, scenes,
  movements, etc...
•The back-end code (script) should
  clearly narrate the story of the
  front-end display.
•Clean code leverages the power of
  the brain to quickly identify and
  associate words and phrases with
Naming Stuff
•The sole purpose of names in code is to
  reveal the intent of the author.
•Choosing the right names can make or
  break future scalability.
•Bad names generate support requests.
•Obscure names destroy narrative.
•Avoid cultural references and slang.
•Good names make everyone happy.
Clean Functions
• Functions should do one thing and be short.
• Function names should be semantic and contain a
  verb.

• Functions need a namespace in WP plugins/
  themes.
  foo_bar(){} vs. prefix_foo_bar(){}

• Long function names are always better than short
  obscure names.

  BAD: addfavclr($u, $c)
  GOOD: add_favorite_color($user_id, $color)

• The name of the function must clearly reveal the
  intent of the function.
Clean Variables
•Variable names define the context of a
  function. A clearly defined function can
  be obfuscated by obscure variable
  names.

•Obscure variable names confuse others
  who edit your code later.
  $u vs. $user_id

•With proper naming, a function should
  read like a paragraph.

•Loop counters are an exception as long
  as their scope is limited. (i.e. $i++)
Clean Commenting
•If it’s necessary to comment about how
  a function works, your code stinketh.

•PHP comments should be used for
  attribution, licensing, phpdoc (for
  generating php-xref, IDE support,
  etc...), directing users to other files/
  layers/plugins.

•Comments quickly become obsolete
  with updates/upgrades.

• Descriptive HTML comments are a no-
  no unless required for attribution.
Clean Formatting
•Keep sibling functions in proximity.
•Indent your code properly to clearly
   show nested expressions.
•Follow Wordpress code/style standards.
•Do it. Now.

http://codex.wordpress.org/WordPress_Coding_Standards
Duplication
•Learn Wordpress functionality so
  you don’t create a duplicate function.
 •global $is_lynx, $is_gecko, $is_IE, $is_opera,
  Browser Detection:
   $is_NS4, $is_safari, $is_chrome, $is_iphone;

 •add_filter(‘the_content’, ‘my_function’);
  Global Content Filtering

•Duplication adds server overhead
  and user frustration.
Shortcode Fever
•Shortcodes here, shortcodes there...
  buttons, sliders, TABS, PRICE
  TABLES, LIST ICONS,
  Testimonials,
  DROPCAPS,
  QUOTES OMG
  YAY!!!!!!!
The Shortcode
     Problem
•A user inserts your theme
  shortcodes throughout their content.
•Said user decides to switch themes.
•Shortcodes no longer function and
  create loads of work.
•User loses mind.
The Shortcode Cure
•Stop being proprietary with your
  theme bling.
•Put your shortcodes in a sweet
  plugin.
•Use your new plugin as a loss-leader
  promotion.
Dirty Code Example




     •This can be found in WP Core
•Wordpress core contains a <blink>
  tag. Dead Serious!!! Where is it
  located?
•Where can you find the Wordpress
 Easter Egg?
Thank You!




        Brian Fegter
       @brianfegter
brian@upthemes.com

More Related Content

What's hot

Creative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS BasicsCreative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS Basics
Lukas Oppermann
 
Getting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael HutchinsonGetting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael Hutchinson
Xamarin
 

What's hot (20)

Creating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsCreating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable Needs
 
Epub in the wild
Epub in the wildEpub in the wild
Epub in the wild
 
#eprdctn tools & tips round up
#eprdctn tools & tips round up#eprdctn tools & tips round up
#eprdctn tools & tips round up
 
Remodel your website
Remodel your websiteRemodel your website
Remodel your website
 
Open Standards in the Walled Garden
Open Standards in the Walled GardenOpen Standards in the Walled Garden
Open Standards in the Walled Garden
 
Achieving Beautiful Typography in eBooks
Achieving Beautiful Typography in eBooksAchieving Beautiful Typography in eBooks
Achieving Beautiful Typography in eBooks
 
Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson
Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody HelgesonWordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson
Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson
 
Digital Publishing PDXDMC
Digital Publishing PDXDMCDigital Publishing PDXDMC
Digital Publishing PDXDMC
 
Web Content Management Systems From A Designer's Perspective (Drupal Technica...
Web Content Management Systems From A Designer's Perspective (Drupal Technica...Web Content Management Systems From A Designer's Perspective (Drupal Technica...
Web Content Management Systems From A Designer's Perspective (Drupal Technica...
 
Perfect Styling - How to write better CSS
Perfect Styling - How to write better CSSPerfect Styling - How to write better CSS
Perfect Styling - How to write better CSS
 
Ebook bootcamp
Ebook bootcampEbook bootcamp
Ebook bootcamp
 
Prototyping Accessibility: Booster 2019
Prototyping Accessibility: Booster 2019Prototyping Accessibility: Booster 2019
Prototyping Accessibility: Booster 2019
 
The Role of Design in Accessibility — a11yTO Meet-up
The Role of Design in Accessibility — a11yTO Meet-upThe Role of Design in Accessibility — a11yTO Meet-up
The Role of Design in Accessibility — a11yTO Meet-up
 
Creative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS BasicsCreative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS Basics
 
OOP CSS Presenation
OOP CSS PresenationOOP CSS Presenation
OOP CSS Presenation
 
CSS for Mobile
CSS for MobileCSS for Mobile
CSS for Mobile
 
Getting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael HutchinsonGetting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael Hutchinson
 
SPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery EssentialsSPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery Essentials
 
Getting Started With WordPress Themes for Beginners
Getting Started With WordPress Themes for BeginnersGetting Started With WordPress Themes for Beginners
Getting Started With WordPress Themes for Beginners
 
Down and Dirty EPUB 3
Down and Dirty EPUB 3Down and Dirty EPUB 3
Down and Dirty EPUB 3
 

Viewers also liked

PROEXPOSURE Brazil: going back home
PROEXPOSURE Brazil: going back homePROEXPOSURE Brazil: going back home
PROEXPOSURE Brazil: going back home
PROEXPOSURE CIC
 
PROEXPOSURE Communications Training Courses
PROEXPOSURE Communications Training Courses PROEXPOSURE Communications Training Courses
PROEXPOSURE Communications Training Courses
PROEXPOSURE CIC
 

Viewers also liked (20)

Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Проблемы долговременного хранения действующих и исторических документов, по...
Проблемы долговременного хранения действующих  и исторических документов,  по...Проблемы долговременного хранения действующих  и исторических документов,  по...
Проблемы долговременного хранения действующих и исторических документов, по...
 
Introductie positie in de geschiedenis
Introductie positie in de geschiedenisIntroductie positie in de geschiedenis
Introductie positie in de geschiedenis
 
Так ли уж проста эта простая электронная подпись
Так ли уж проста эта простая электронная подписьТак ли уж проста эта простая электронная подпись
Так ли уж проста эта простая электронная подпись
 
PROEXPOSURE Brazil: going back home
PROEXPOSURE Brazil: going back homePROEXPOSURE Brazil: going back home
PROEXPOSURE Brazil: going back home
 
СЭД: Новые задачи, новые проблемы, новые стандарты
СЭД: Новые задачи, новые проблемы, новые стандартыСЭД: Новые задачи, новые проблемы, новые стандарты
СЭД: Новые задачи, новые проблемы, новые стандарты
 
Shopping Cart Software for SEO
Shopping Cart Software for SEOShopping Cart Software for SEO
Shopping Cart Software for SEO
 
Okra - Ik vinde de aarde leuk!
Okra - Ik  vinde de aarde leuk!Okra - Ik  vinde de aarde leuk!
Okra - Ik vinde de aarde leuk!
 
Отечественная и зарубежная законодательная и нормативная база организации вне...
Отечественная и зарубежная законодательная и нормативная база организации вне...Отечественная и зарубежная законодательная и нормативная база организации вне...
Отечественная и зарубежная законодательная и нормативная база организации вне...
 
PROEXPOSURE Communications Training Courses
PROEXPOSURE Communications Training Courses PROEXPOSURE Communications Training Courses
PROEXPOSURE Communications Training Courses
 
Economics 1 1
Economics 1 1Economics 1 1
Economics 1 1
 
Текущие проблемы в области законодательного регулирования управления документ...
Текущие проблемы в области законодательного регулирования управления документ...Текущие проблемы в области законодательного регулирования управления документ...
Текущие проблемы в области законодательного регулирования управления документ...
 
Консультационные услуги сегодня и завтра
Консультационные услуги  сегодня и завтраКонсультационные услуги  сегодня и завтра
Консультационные услуги сегодня и завтра
 
Asp.net 5 en linux , herramientas e integración
Asp.net 5 en linux , herramientas e integraciónAsp.net 5 en linux , herramientas e integración
Asp.net 5 en linux , herramientas e integración
 
De Koep (Jef Van Eyck)
De Koep (Jef Van Eyck)De Koep (Jef Van Eyck)
De Koep (Jef Van Eyck)
 
д-р Лючиана Дюранти – Дополнение к презентации о проекте InterPARES Trust
д-р Лючиана Дюранти – Дополнение к презентации о проекте InterPARES Trustд-р Лючиана Дюранти – Дополнение к презентации о проекте InterPARES Trust
д-р Лючиана Дюранти – Дополнение к презентации о проекте InterPARES Trust
 
Ontwikkelen van een integriteitsbeleid (Heidi Paesen)
Ontwikkelen van een integriteitsbeleid (Heidi Paesen)Ontwikkelen van een integriteitsbeleid (Heidi Paesen)
Ontwikkelen van een integriteitsbeleid (Heidi Paesen)
 
มาเขียนโค้ดแย่ๆ กันเถอะ
มาเขียนโค้ดแย่ๆ กันเถอะมาเขียนโค้ดแย่ๆ กันเถอะ
มาเขียนโค้ดแย่ๆ กันเถอะ
 
Workshop sociusonderzoek
Workshop sociusonderzoekWorkshop sociusonderzoek
Workshop sociusonderzoek
 
Джованни Сено - Законодательно-нормативная база и использование электронных д...
Джованни Сено - Законодательно-нормативная база и использование электронных д...Джованни Сено - Законодательно-нормативная база и использование электронных д...
Джованни Сено - Законодательно-нормативная база и использование электронных д...
 

Similar to Wordcamp St. Louis - Clean Coding

Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
Mediacurrent
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
Joe Casabona
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
Stephanie Leary
 

Similar to Wordcamp St. Louis - Clean Coding (20)

WordPress: A Designer's CMS
WordPress: A Designer's CMSWordPress: A Designer's CMS
WordPress: A Designer's CMS
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
 
WordPress Theming Best Practices
WordPress Theming Best PracticesWordPress Theming Best Practices
WordPress Theming Best Practices
 
presentation
presentationpresentation
presentation
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
WordPress Themes and Plugins
WordPress Themes and PluginsWordPress Themes and Plugins
WordPress Themes and Plugins
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate Workshop
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
 
Making Your Site Printable: CSS Summit 2014
Making Your Site Printable: CSS Summit 2014Making Your Site Printable: CSS Summit 2014
Making Your Site Printable: CSS Summit 2014
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
Wp 3hr-course
Wp 3hr-courseWp 3hr-course
Wp 3hr-course
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
 
Design Without Types
Design Without TypesDesign Without Types
Design Without Types
 
WordPress A CMS for Beginners, Geeks and Those In-Between
WordPress A CMS for Beginners, Geeks and Those In-BetweenWordPress A CMS for Beginners, Geeks and Those In-Between
WordPress A CMS for Beginners, Geeks and Those In-Between
 
Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016
 
Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme Framework
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Wordcamp St. Louis - Clean Coding

  • 1.
  • 2. Where to Find Me •brian@upthemes.com •Twitter: brianfegter •github: inspectorfegter •The Interwebz: coderrr.com
  • 3. About Me •Live near Orlando, Florida (Titusville = the booming metropolis) •Hobbies: photography, fountain pens, planking (not) •I work for UpThemes.com and LiftUX.com as a lead developer •Favorite vegetable: popcorn
  • 4. The Anatomy of a Commercial Wordpress Theme A Developmental Overview
  • 5. The TRUTH about commercial themes... •There is not a single theme that does not require support. You must build a support system. •Rarely does a purchased theme remain in its original condition. •A strong percentage of buyers are international.
  • 6. Ground Zero SOLID Template Architecture http://codex.wordpress.org/Theme_Development
  • 7. On your mark, get set...STOP Understand Template Hierarchy http://codex.wordpress.org/Template_Hierarchy
  • 9. Template Structure CREDO I pledge to: •Follow template hierarchy patterns •Clearly name my supporting files/folders •Never, never, ever, NEVER, ever nest a plugin inside my theme •Clarity over cleverness
  • 10. Using Wordpress Assets •Clearly name your sidebars •Use custom post types only when necessary •Define theme locations for menus •Localize your strings - __() _e() are your friends •Set WP image sizes vs. image resizing scripts (TimThumb, etc...) •Leverage the power of CSS with body_class() and post_class()
  • 11. To use or not to use Theme Options...
  • 15. Stupid-Easy Implementation •Include one file in functions.php require_once(‘admin/admin.php’); •Call global $up_options; •Retrieve your option value by ID $up_options->my_awesome_id
  • 16. Theme Options User Health Alert! •Too many options kill brain cells and raise blood pressure. •No options make users MAD and could lead to permanent psychosis. •Obscure options cause road rage and have been linked to chronic multiple- punctuationitis!!!!!!!!!!!!!
  • 17. Code is Poetry •Code is Narrative. •Your theme tells a story and has an intended plot, characters, scenes, movements, etc... •The back-end code (script) should clearly narrate the story of the front-end display. •Clean code leverages the power of the brain to quickly identify and associate words and phrases with
  • 18. Naming Stuff •The sole purpose of names in code is to reveal the intent of the author. •Choosing the right names can make or break future scalability. •Bad names generate support requests. •Obscure names destroy narrative. •Avoid cultural references and slang. •Good names make everyone happy.
  • 19. Clean Functions • Functions should do one thing and be short. • Function names should be semantic and contain a verb. • Functions need a namespace in WP plugins/ themes. foo_bar(){} vs. prefix_foo_bar(){} • Long function names are always better than short obscure names. BAD: addfavclr($u, $c) GOOD: add_favorite_color($user_id, $color) • The name of the function must clearly reveal the intent of the function.
  • 20. Clean Variables •Variable names define the context of a function. A clearly defined function can be obfuscated by obscure variable names. •Obscure variable names confuse others who edit your code later. $u vs. $user_id •With proper naming, a function should read like a paragraph. •Loop counters are an exception as long as their scope is limited. (i.e. $i++)
  • 21. Clean Commenting •If it’s necessary to comment about how a function works, your code stinketh. •PHP comments should be used for attribution, licensing, phpdoc (for generating php-xref, IDE support, etc...), directing users to other files/ layers/plugins. •Comments quickly become obsolete with updates/upgrades. • Descriptive HTML comments are a no- no unless required for attribution.
  • 22. Clean Formatting •Keep sibling functions in proximity. •Indent your code properly to clearly show nested expressions. •Follow Wordpress code/style standards. •Do it. Now. http://codex.wordpress.org/WordPress_Coding_Standards
  • 23. Duplication •Learn Wordpress functionality so you don’t create a duplicate function. •global $is_lynx, $is_gecko, $is_IE, $is_opera, Browser Detection: $is_NS4, $is_safari, $is_chrome, $is_iphone; •add_filter(‘the_content’, ‘my_function’); Global Content Filtering •Duplication adds server overhead and user frustration.
  • 24. Shortcode Fever •Shortcodes here, shortcodes there... buttons, sliders, TABS, PRICE TABLES, LIST ICONS, Testimonials, DROPCAPS, QUOTES OMG YAY!!!!!!!
  • 25. The Shortcode Problem •A user inserts your theme shortcodes throughout their content. •Said user decides to switch themes. •Shortcodes no longer function and create loads of work. •User loses mind.
  • 26. The Shortcode Cure •Stop being proprietary with your theme bling. •Put your shortcodes in a sweet plugin. •Use your new plugin as a loss-leader promotion.
  • 27. Dirty Code Example •This can be found in WP Core
  • 28. •Wordpress core contains a <blink> tag. Dead Serious!!! Where is it located?
  • 29. •Where can you find the Wordpress Easter Egg?
  • 30. Thank You! Brian Fegter @brianfegter brian@upthemes.com

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n