Successfully reported this slideshow.
Your SlideShare is downloading. ×

Five events in the life of every WordPress request you should know

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 31 Ad

More Related Content

Slideshows for you (20)

Advertisement

Similar to Five events in the life of every WordPress request you should know (20)

More from Caldera Labs (15)

Advertisement

Five events in the life of every WordPress request you should know

  1. 1. Five Events In The Life Of Every WordPress Request You Should Know Josh Pollock
  2. 2. How Do We Get From This?
  3. 3. To This
  4. 4. Magic?
  5. 5. You're About To Get Super Powers
  6. 6. Let's Talk About Hooks A hook is an event
  7. 7. Actions Do Something At This Point do_action( 'something' ); add_action( 'something', function() { echo 'Doing Something'; });
  8. 8. Filters Change Something At This Point $something = apply_filters( 'something', 'something' ); add_filter( 'something', function( $something) { $something = 'something else'; return $something });
  9. 9. You've Seen This Before add_filter( 'the_content', function( $content ) { $content .= '<a href="#">Share</a>'; return $content; } add_action( 'wp_head', function() { echo "<script>alert( KHAAAAAAN!' ); </script>"; }
  10. 10. What Does WordPress Do?
  11. 11. Five Events You Should Know
  12. 12. init /wp-includes/class-wp.php
  13. 13. Fires When WordPress Is Loaded /wp-includes/class-wp.php
  14. 14. Before: ● muplugins_loaded ● plugins_loaded ● setup_theme ● after_setup_theme After: ● wp_loaded Related Actions
  15. 15. request /wp-includes/class-wp.php
  16. 16. Modifies Query Vars Before Building WP_Query /wp-includes/class-wp.php
  17. 17. Actions: ● parse_request ● send_headers Filters: ● query_string ● wp_headers Related Hooks
  18. 18. pre_get_posts /wp-includes/query.php
  19. 19. Modifies WP_Query Arguments Before Querying /wp-includes/query.php
  20. 20. Actions: ● start_loop ● end_loop Filters: ● the_posts ● the_post Related Hooks
  21. 21. template_redirect /wp-includes/template.php
  22. 22. Before Choosing A Template /wp-includes/template.php
  23. 23. Do something instead of the template hierarchy. WHY?
  24. 24. THEN THE TEMPLATE HIERARCHY HAPPENS
  25. 25. template_includes /wp-includes/template.php
  26. 26. Change the template selected by the template hierarchy WHY?
  27. 27. CalderaWP.com IngotHQ.com @Josh412 JoshPress.net

×