SlideShare uma empresa Scribd logo
1 de 18
DOING_IT_RIGHT() WITH
    WORDPRESS
            Ryan Duff
      Fusionized Technology
WHO AM I



• Using WordPress   since 2004 (version 1.2)

• WordPress   Professional for hire
WHY DO IT RIGHT


• Save   yourself time

• Save   others time

• Save   your clients money

• Save   everybody from headaches
WAYS TO DO IT RIGHT

• Learn   to organize your code

•          ... document your code

•          ... optimize your code

• Don’t   reinvent the wheel

• Action   Hooks and Filters

• Other    very bad things to avoid
FIRST THINGS FIRST

• Use   the debug bar plugin


 define(‘WP_DEBUG’, true);
 define(‘WP_DEBUG_DISPLAY, false);
 define(‘SAVEQUERIES’, true);
ORGANIZE YOUR CODE


• What      goes in a plugin?

• What      goes in a theme?

• Utilize   mu-plugins/
ORGANIZE YOUR CODE




http://codex.wordpress.org/Template_Hierarchy
DOCUMENT YOUR CODE
/**
 * Simple and uniform HTTP request API.
 *
 * Standardizes the HTTP requests for WordPress. Handles cookies, gzip
encoding and decoding, chunk
 * decoding, if HTTP 1.1 and various other difficult HTTP protocol
implementations.
 *
 * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal
 *
 * @package WordPress
 * @subpackage HTTP
 * @since 2.7.0
 */
OPTIMIZE YOUR CODE



• Cache

• Get   rid of rotten database queries
OPTIMIZE YOUR CODE

set_transient( $transient, $value, $expiration );

get_transient( $transient );

delete_transient( $transient );
OPTIMIZE YOUR CODE


• Make   sure the code you’re expecting matches

• Use   $wpdb class in the correct cases, WP_Query otherwise

• Sanitize   everything http://codex.wordpress.org/Data_Validation
DON’T REINVENT THE WHEEL



• Clever   code is not clever.

• Use   built in APIs and methods
WORDPRESS APIS
•   Dashboard widgets    •   Plugin

•   Database             •   Rewrite

•   HTTP                 •   Settings

•   File Header          •   Shortcode

•   Filesystem           •   Theme modification

•   Metadata             •   Transients

•   Options              •   Widgets
ACTION HOOKS AND FILTERS



• Hooks     are places to DO things

• Filters   are ways to CHANGE things
MORE THINGS NOT TO DO


• Don’t   downgrade jQuery

• Don’t   create unnecessary settings

• Don’t   forget to update
SECURE CODE

• esc_html()

• esc_attr()

• esc_url()

• $wpdb->prepare()



        http://codex.wordpress.org/Data_Validation
HOW TO LEARN MORE



• Read   the code and contribute http://core.trac.wordpress.org

• Ask   questions in #wordpress on freenode
QUESTIONS?

       Ryan Duff
Fusionized Technology
 http://fusionized.com
      @ryancduff

Mais conteúdo relacionado

Mais procurados

Jekyll Presentation Slides
Jekyll Presentation SlidesJekyll Presentation Slides
Jekyll Presentation SlidesCurtis Miller
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest frameworkBlank Chen
 
Saigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupSaigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupTriết Sài Gòn
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPressadamsilverstein
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Thinkful
 
What's up with Drupal 7?
What's up with Drupal 7?What's up with Drupal 7?
What's up with Drupal 7?Gábor Hojtsy
 
High Performance Front-End Development
High Performance Front-End DevelopmentHigh Performance Front-End Development
High Performance Front-End Developmentdrywallbmb
 
Getting started with wordpress hosting and security
Getting started with wordpress hosting and securityGetting started with wordpress hosting and security
Getting started with wordpress hosting and securityWP Pittsburgh Meetup Group
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin developmentLuc De Brouwer
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009Ralph Whitbeck
 
Js placement
Js placementJs placement
Js placementSireesh K
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScriptRaymond Camden
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoknaddison
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with RailsBasayel Said
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginnersjohnpbloch
 

Mais procurados (20)

Jekyll Presentation Slides
Jekyll Presentation SlidesJekyll Presentation Slides
Jekyll Presentation Slides
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest framework
 
Drupal Bootcamp Mcn2008
Drupal Bootcamp   Mcn2008Drupal Bootcamp   Mcn2008
Drupal Bootcamp Mcn2008
 
Saigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupSaigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress Meetup
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
What's up with Drupal 7?
What's up with Drupal 7?What's up with Drupal 7?
What's up with Drupal 7?
 
High Performance Front-End Development
High Performance Front-End DevelopmentHigh Performance Front-End Development
High Performance Front-End Development
 
Getting started with wordpress hosting and security
Getting started with wordpress hosting and securityGetting started with wordpress hosting and security
Getting started with wordpress hosting and security
 
Securing your web apps now
Securing your web apps nowSecuring your web apps now
Securing your web apps now
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin development
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009
 
Js placement
Js placementJs placement
Js placement
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicago
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with Rails
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginners
 

Semelhante a doing_it_right() with WordPress

Getting Started With Xdebug
Getting Started With XdebugGetting Started With Xdebug
Getting Started With XdebugJeremy Ward
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniterJamshid Hashimi
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressRami Sayar
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’sVisug
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpressRan Bar-Zik
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeCale Hoopes
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
 
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 Dutyreedmaniac
 
Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Barry Kooij
 
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 DutyLeslie Doherty
 
Protect Your WordPress From The Inside Out
Protect Your WordPress From The Inside OutProtect Your WordPress From The Inside Out
Protect Your WordPress From The Inside OutSiteGround.com
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
 

Semelhante a doing_it_right() with WordPress (20)

Getting Started With Xdebug
Getting Started With XdebugGetting Started With Xdebug
Getting Started With Xdebug
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpress
 
Hacking Wordpress Plugins
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress Plugins
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
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
 
Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014
 
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
 
Protect Your WordPress From The Inside Out
Protect Your WordPress From The Inside OutProtect Your WordPress From The Inside Out
Protect Your WordPress From The Inside Out
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
 

Mais de ryanduff

Making Magic with WP-CLI
Making Magic with WP-CLIMaking Magic with WP-CLI
Making Magic with WP-CLIryanduff
 
Ryan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP APIRyan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP APIryanduff
 
WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin
WordCamp Raleigh 2015 - So You Want to Build and Release a PluginWordCamp Raleigh 2015 - So You Want to Build and Release a Plugin
WordCamp Raleigh 2015 - So You Want to Build and Release a Pluginryanduff
 
WordCamp Lancaster - Choosing WordPress Themes and Plugins
WordCamp Lancaster - Choosing WordPress Themes and PluginsWordCamp Lancaster - Choosing WordPress Themes and Plugins
WordCamp Lancaster - Choosing WordPress Themes and Pluginsryanduff
 
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014ryanduff
 
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014ryanduff
 
Extending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIExtending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIryanduff
 
WordPress Custom Post Types Part 1: Back End
WordPress Custom Post Types Part 1: Back EndWordPress Custom Post Types Part 1: Back End
WordPress Custom Post Types Part 1: Back Endryanduff
 
Productivity 101: Making a Easily Redeployable Dev Environment with Subversion
Productivity 101: Making a Easily Redeployable Dev Environment with SubversionProductivity 101: Making a Easily Redeployable Dev Environment with Subversion
Productivity 101: Making a Easily Redeployable Dev Environment with Subversionryanduff
 
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clients
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your ClientsWhy Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clients
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clientsryanduff
 
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with SubversionProductivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversionryanduff
 

Mais de ryanduff (11)

Making Magic with WP-CLI
Making Magic with WP-CLIMaking Magic with WP-CLI
Making Magic with WP-CLI
 
Ryan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP APIRyan Duff 2015 WordCamp US HTTP API
Ryan Duff 2015 WordCamp US HTTP API
 
WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin
WordCamp Raleigh 2015 - So You Want to Build and Release a PluginWordCamp Raleigh 2015 - So You Want to Build and Release a Plugin
WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin
 
WordCamp Lancaster - Choosing WordPress Themes and Plugins
WordCamp Lancaster - Choosing WordPress Themes and PluginsWordCamp Lancaster - Choosing WordPress Themes and Plugins
WordCamp Lancaster - Choosing WordPress Themes and Plugins
 
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
Extending your WordPress Toolbelt with WP-CLI - WordCamp Austin 2014
 
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
 
Extending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLIExtending Your WordPress Toolbelt with WP-CLI
Extending Your WordPress Toolbelt with WP-CLI
 
WordPress Custom Post Types Part 1: Back End
WordPress Custom Post Types Part 1: Back EndWordPress Custom Post Types Part 1: Back End
WordPress Custom Post Types Part 1: Back End
 
Productivity 101: Making a Easily Redeployable Dev Environment with Subversion
Productivity 101: Making a Easily Redeployable Dev Environment with SubversionProductivity 101: Making a Easily Redeployable Dev Environment with Subversion
Productivity 101: Making a Easily Redeployable Dev Environment with Subversion
 
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clients
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your ClientsWhy Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clients
Why Switching To WordPress 3.0 Is The Best Thing You Can Do For Your Clients
 
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with SubversionProductivity 101: Making a Easily Re-deployable Dev Environment with Subversion
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
 

doing_it_right() with WordPress

  • 1. DOING_IT_RIGHT() WITH WORDPRESS Ryan Duff Fusionized Technology
  • 2. WHO AM I • Using WordPress since 2004 (version 1.2) • WordPress Professional for hire
  • 3. WHY DO IT RIGHT • Save yourself time • Save others time • Save your clients money • Save everybody from headaches
  • 4. WAYS TO DO IT RIGHT • Learn to organize your code • ... document your code • ... optimize your code • Don’t reinvent the wheel • Action Hooks and Filters • Other very bad things to avoid
  • 5. FIRST THINGS FIRST • Use the debug bar plugin define(‘WP_DEBUG’, true); define(‘WP_DEBUG_DISPLAY, false); define(‘SAVEQUERIES’, true);
  • 6. ORGANIZE YOUR CODE • What goes in a plugin? • What goes in a theme? • Utilize mu-plugins/
  • 8. DOCUMENT YOUR CODE /** * Simple and uniform HTTP request API. * * Standardizes the HTTP requests for WordPress. Handles cookies, gzip encoding and decoding, chunk * decoding, if HTTP 1.1 and various other difficult HTTP protocol implementations. * * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal * * @package WordPress * @subpackage HTTP * @since 2.7.0 */
  • 9. OPTIMIZE YOUR CODE • Cache • Get rid of rotten database queries
  • 10. OPTIMIZE YOUR CODE set_transient( $transient, $value, $expiration ); get_transient( $transient ); delete_transient( $transient );
  • 11. OPTIMIZE YOUR CODE • Make sure the code you’re expecting matches • Use $wpdb class in the correct cases, WP_Query otherwise • Sanitize everything http://codex.wordpress.org/Data_Validation
  • 12. DON’T REINVENT THE WHEEL • Clever code is not clever. • Use built in APIs and methods
  • 13. WORDPRESS APIS • Dashboard widgets • Plugin • Database • Rewrite • HTTP • Settings • File Header • Shortcode • Filesystem • Theme modification • Metadata • Transients • Options • Widgets
  • 14. ACTION HOOKS AND FILTERS • Hooks are places to DO things • Filters are ways to CHANGE things
  • 15. MORE THINGS NOT TO DO • Don’t downgrade jQuery • Don’t create unnecessary settings • Don’t forget to update
  • 16. SECURE CODE • esc_html() • esc_attr() • esc_url() • $wpdb->prepare() http://codex.wordpress.org/Data_Validation
  • 17. HOW TO LEARN MORE • Read the code and contribute http://core.trac.wordpress.org • Ask questions in #wordpress on freenode
  • 18. QUESTIONS? Ryan Duff Fusionized Technology http://fusionized.com @ryancduff

Notas do Editor

  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