Your SlideShare is downloading. ×
Wordcamp St. Louis - Clean Coding
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Wordcamp St. Louis - Clean Coding

403
views

Published on

Published in: Technology, Business

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
403
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Where to Find Me•brian@upthemes.com•Twitter: brianfegter•github: inspectorfegter•The Interwebz: coderrr.com
    • 2. 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
    • 3. The Anatomy of a Commercial Wordpress Theme A Developmental Overview
    • 4. 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.
    • 5. Ground Zero SOLID Template Architecturehttp://codex.wordpress.org/Theme_Development
    • 6. On your mark, get set...STOP Understand Template Hierarchy http://codex.wordpress.org/Template_Hierarchy
    • 7. Hierarchy Diagramhttp://codex.wordpress.org/Template_Hierarchy
    • 8. 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
    • 9. 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()
    • 10. To use ornot to use ThemeOptions...
    • 11. Our Options Frameworkgithub.com/chriswallace/UpThemes-Framework
    • 12. Painless Option Creation
    • 13. Bodacious Functionality
    • 14. 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
    • 15. 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!!!!!!!!!!!!!
    • 16. 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
    • 17. 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.
    • 18. 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.
    • 19. 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++)
    • 20. 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.
    • 21. 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
    • 22. 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.
    • 23. Shortcode Fever•Shortcodes here, shortcodes there... buttons, sliders, TABS, PRICE TABLES, LIST ICONS, Testimonials, DROPCAPS, QUOTES OMG YAY!!!!!!!
    • 24. 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.
    • 25. 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.
    • 26. Dirty Code Example •This can be found in WP Core
    • 27. •Wordpress core contains a <blink> tag. Dead Serious!!! Where is it located?
    • 28. •Where can you find the Wordpress Easter Egg?
    • 29. Thank You! Brian Fegter @brianfegterbrian@upthemes.com