WordPress Coding Standards & WP Hooks

2,528 views

Published on

A short presentation on WordPress Coding Standards & WP Hooks.

Published in: Technology, Business
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,528
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
151
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

WordPress Coding Standards & WP Hooks

  1. 1. WP Coding Standards & Hooks
  2. 2. WP Coding Standards • HTML Coding Standard • CSS Coding Standard • JS Coding Standard • PHP Coding Standard
  3. 3. HTML Coding Standards • All tags must be closed properly • All tags & attributes must be written in lowercase • Indent your code using Tab, NOT Space
  4. 4. CSS Coding Standards • Use meaningful id or class names • Use hyphens(-) when naming selectors • Avoid CamelCase & Underscores
  5. 5. JS Coding Standards • Use braces for multiline statement • Use CamelCase, NOT underscore when naming variables, functions • Use jQuery noConflict
  6. 6. PHP Coding Standards • Use lowercase letters for naming variables, functions, arguments, never CamelCase. • No shorthand PHP tags, always use full PHP tags. • Use Single quotes(‘) or double quotes(“) when appropriate
  7. 7. PHP Coding Standards • Always put spaces after commas, and on both sides of logical, comparison, string and assignment operators. • Make your code readable; readability is more important than cleverness.
  8. 8. WP Hooks
  9. 9. WordPress Actions What are they? Actions are triggered by specific events that take place in WordPress. Your can respond to the event by executing a function.
  10. 10. Example: WP Actions • after_setup_theme • wp_enqueue_scripts • wp_head • wp_footer • admin_head
  11. 11. Create your own Action!
  12. 12. WordPress Filters What are they? Filters are functions that WordPress passes data through at certain points in execution.
  13. 13. Example: WordPress Filters • body_class • post_class • excerpt_length • excerpt_more • pre_get_posts
  14. 14. Create your own filter!
  15. 15. Actions Vs. Filters
  16. 16. Got a Question?
  17. 17. Coding Standard Resources • http://codex.wordpress.org/WordPress_Coding_Standards • http://wp.tutsplus.com/articles/cheat-sheets/the- wordpress-coding-standards-an-introduction/ • http://validator.w3.org/ • http://google.com
  18. 18. Hook Resources • http://codex.wordpress.org/Plugin_API/Action_Reference • http://codex.wordpress.org/Plugin_API/Filter_Reference • http://google.com

×