php[world] hooks, actions and filters oh my!

16
@DAVIDLAIETTA HOOKS, ACTIONS, AND FILTERS OH MY!

Upload: david-laietta

Post on 14-Apr-2017

305 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: php[world] Hooks, Actions and Filters Oh My!

@DAVIDLAIETTAHOOKS, ACTIONS, AND FILTERS OH MY!

Page 2: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

WHY USE HOOKS?

▸ Most WordPress features use actions and filters that you can modify to change how WordPress fundamentally works

▸ You can make complex changes easily without editing core, or existing plugins or themes that you’ve purchased

▸ Make changes at the source, instead of hacking away

▸ Upgrade without worry of losing your modifications

▸ Enable and disable your changes easily

obm.io/php2015-hooks

Page 3: php[world] Hooks, Actions and Filters Oh My!

Hooks: Places where you can add your own code.

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 4: php[world] Hooks, Actions and Filters Oh My!

Mr. WordPress

HOW A HOOK IS BORN

I’m going to do this thing.

Before you do your thing, I’ve got this other thing that I want to do.

Mr. WordPress

Ms. Plugin

Ok, do your thing, then I’ll do my thing!

obm.io/php2015-hooks

Page 5: php[world] Hooks, Actions and Filters Oh My!

Actions: Hooks that let you do something when something else happens

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 6: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 7: php[world] Hooks, Actions and Filters Oh My!

Filters: Hooks that let you modify data before or after interacting with the WordPress database

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 8: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 9: php[world] Hooks, Actions and Filters Oh My!

do_action()

Setting up our own hooks!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 10: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 11: php[world] Hooks, Actions and Filters Oh My!

A SAMPLE GENESIS LANDING PAGE

obm.io/php2015-hooks

Page 12: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

EXAMPLE: CHANGING EXCERPT LENGTH WITH A FILTER

obm.io/php2015-hooks

Page 13: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

EXAMPLE: GRAVITY FORMS FILTER

obm.io/php2015-hooks

Page 14: php[world] Hooks, Actions and Filters Oh My!

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

EXAMPLE: WOOCOMMERCE ACTION AND FILTER

obm.io/php2015-hooks

Page 15: php[world] Hooks, Actions and Filters Oh My!

RESOURCES

▸ http://codex.wordpress.org/Plugin_API/Action_Reference

▸ http://codex.wordpress.org/Plugin_API/Filter_Reference

▸ http://blog.teamtreehouse.com/hooks-wordpress-actions-filters-examples

▸ https://docs.woothemes.com/document/hooks/

▸ https://www.gravityhelp.com/documentation/category/hooks/

▸ http://genesistutorials.com/visual-hook-guide/

HOOKS, ACTIONS, AND FILTERS OH MY! @DAVIDLAIETTA

obm.io/php2015-hooks

Page 16: php[world] Hooks, Actions and Filters Oh My!

@davidlaietta

obm.io/php2015-hooks

QUESTIONS?