SlideShare una empresa de Scribd logo
1 de 17
doing_it_right() with
    Wordpress
              Ryan Duff
    Harrisburg WordPress Meetup
         February 19th, 2013
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
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

Más contenido relacionado

La actualidad más candente

"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...Sudeep Balchhaudi
 
Ten Things You Should Know About WordPress
Ten Things You Should Know About WordPressTen Things You Should Know About WordPress
Ten Things You Should Know About WordPresssereedmedia
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)christopherfross
 
Creating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPressCreating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPressJason Yingling
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHPTaylor Lovett
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Working with WordPress in a Team Environment
Working with WordPress in a Team EnvironmentWorking with WordPress in a Team Environment
Working with WordPress in a Team Environmentchristopherfross
 
A11y Conference Talk: Building an Accessible WordPress Theme
A11y Conference Talk: Building an Accessible WordPress ThemeA11y Conference Talk: Building an Accessible WordPress Theme
A11y Conference Talk: Building an Accessible WordPress ThemeTomAuger
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressandrewnacin
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPTaylor Lovett
 
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
 
Multi tenant CMSes using php
Multi tenant CMSes using phpMulti tenant CMSes using php
Multi tenant CMSes using phpkae-verens
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchTaylor Lovett
 
Word press development for non developers
Word press development for non developers Word press development for non developers
Word press development for non developers Jessica C. Gardner
 
WordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityWordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityThe Toolbox, Inc.
 
Effective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentEffective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentAlexander Kress
 

La actualidad más candente (20)

"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
 
Ten Things You Should Know About WordPress
Ten Things You Should Know About WordPressTen Things You Should Know About WordPress
Ten Things You Should Know About WordPress
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
 
Creating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPressCreating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPress
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHP
 
WordPress plugins
WordPress pluginsWordPress plugins
WordPress plugins
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Working with WordPress in a Team Environment
Working with WordPress in a Team EnvironmentWorking with WordPress in a Team Environment
Working with WordPress in a Team Environment
 
A11y Conference Talk: Building an Accessible WordPress Theme
A11y Conference Talk: Building an Accessible WordPress ThemeA11y Conference Talk: Building an Accessible WordPress Theme
A11y Conference Talk: Building an Accessible WordPress Theme
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPress
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWP
 
Introducing Wordpress Multitenancy
Introducing Wordpress MultitenancyIntroducing Wordpress Multitenancy
Introducing Wordpress Multitenancy
 
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
 
Multi tenant CMSes using php
Multi tenant CMSes using phpMulti tenant CMSes using php
Multi tenant CMSes using php
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
 
Word press development for non developers
Word press development for non developers Word press development for non developers
Word press development for non developers
 
WordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityWordPress Fav Plugins & Security
WordPress Fav Plugins & Security
 
Effective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentEffective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven Development
 

Similar a WordPress Harrisburg Meetup - Best Practices

Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Barry Kooij
 
Getting Started With Xdebug
Getting Started With XdebugGetting Started With Xdebug
Getting Started With XdebugJeremy Ward
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressRami Sayar
 
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
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
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
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in schoolMichael Galpin
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeCale Hoopes
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your websitehernanibf
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpressRan Bar-Zik
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterpriseTaylor Lovett
 
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"Andi Rustandi Djunaedi
 
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
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security rightGábor Hojtsy
 
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
 

Similar a WordPress Harrisburg Meetup - Best Practices (20)

Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014
 
Getting Started With Xdebug
Getting Started With XdebugGetting Started With Xdebug
Getting Started With Xdebug
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
Hacking Wordpress Plugins
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress Plugins
 
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)
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
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)
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your website
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpress
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"
Tech IT Easy x DevTalk : "Secure Your Coding with OWASP"
 
Securing your web apps now
Securing your web apps nowSecuring your web apps now
Securing your web apps now
 
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
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
 
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
 

Más 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
 

Más 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
 

WordPress Harrisburg Meetup - Best Practices

  • 1. doing_it_right() with Wordpress Ryan Duff Harrisburg WordPress Meetup February 19th, 2013
  • 2. Why do it right • Save yourself time • Save others time • Save your clients money • Save everybody from headaches
  • 3. 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
  • 4. First things first • Use the debug bar plugin define(‘WP_DEBUG’, true); define(‘WP_DEBUG_DISPLAY, false); define(‘SAVEQUERIES’, true);
  • 5. Organize your code • What goes in a plugin? • What goes in a theme? • Utilize mu-plugins/
  • 7. 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 */
  • 8. Optimize your code • Cache • Get rid of rotten database queries
  • 9. Optimize your code set_transient( $transient, $value, $expiration ); get_transient( $transient ); delete_transient( $transient );
  • 10. 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
  • 11. Don’t reinvent the wheel • Clever code is not clever. • Use built in APIs and methods
  • 13. Action hooks and filters • Hooks are places to DO things • Filters are ways to CHANGE things
  • 14. More things not to do • Don’t downgrade jQuery • Don’t create unnecessary settings • Don’t forget to update
  • 15. Secure code • esc_html() • esc_attr() • esc_url() • $wpdb->prepare() http://codex.wordpress.org/Data_Validation
  • 16. How to learn more • Read the code and contribute http://core.trac.wordpress.org • Ask questions in #wordpress on freenode
  • 17. Questions? Ryan Duff Fusionized Technology http://fusionized.com @ryancduff