Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Understanding WordPress Filters and Actions
1. build create W O R D C A M P C H I C A G O
W O R D P R E S S F I LT E R S &
A C T I O N S
U N D E R S TA N D I N G
build create W O R D C A M P C H I C A G O
2. build create W O R D C A M P C H I C A G O
H I .
Designer, developer,
marketer, shit-talker, etc.
Owner build/create studios
@buildcreate @wilsonography
buildcreate.com
I ’ M I A N , N I C E T O M E E T Y O U .
3. build create W O R D C A M P C H I C A G O
M Y S E L F I S H G O A L S F O R Y O U
I want you to walk away from this feeling a little less
hacky, a little more informed, and most of all inspired.
I want you to have an “Ah ha!” moment, where suddenly
your understanding of WordPress becomes that much
clearer, and you can’t wait to get out of this room to try
out your new knowledge.
Here goes nothing…
4. build create W O R D C A M P C H I C A G O
A W O R L D W I T H O U T H O O K S
5. build create W O R D C A M P C H I C A G O
I T ’ S P R E T T Y D A M N H A C K Y
• Including extra PHP files for ajax
requests
• Hacking into plugins to change
display/functionality
• Hacking *gasp* WP core files
• Hacking theme files (when you
should be using a child theme)
• Hackity hack hack hack.
6. build create W O R D C A M P C H I C A G O
L E T ’ S TA L K A B O U T H O O K S
“Hooks enable us to literally hook into parts of the
WordPress page lifecycle to retrieve, insert, or modify
data, or they allow us to take certain actions behind the
scenes.”
- T O M M C FA R L I N @ T U T S P L U S
7. build create W O R D C A M P C H I C A G O
Where does all of this
fit into the WP
loading process?
8. build create W O R D C A M P C H I C A G O
S O T H E Y ’ R E B O T H H O O K S , T H E Y C A N K E E P
M E F R O M H A C K I N G M Y W O R D P R E S S
I N S TA L L T O S H R E D S W I T H M Y I N E P T I T U D E ,
I G E T T H AT, W H AT ’ S T H E D I F F E R E N C E ?
9. build create W O R D C A M P C H I C A G O
F I LT E R S
• Applying changes to
content/data
• Uses functions:
• apply_filters()
• add_filters()
A C T I O N S
• Hooks your functions into
an action in WP
• Uses functions:
• do_action()
• add_action()
10. build create W O R D C A M P C H I C A G O
F I LT E R S
• Change something you’re
pulling out of WP
• Change something you’re
putting into the WP database
A C T I O N S
• Using WP Ajax
• Tying into existing WP
processes, like sending email
• Adding styles or js to the
page
W H E N S H O U L D W E U S E T H E S E
L O V E LY H O O K S ?
11. build create W O R D C A M P C H I C A G O
A K A A L L T H E D A M N T I M E .
I T ’ S F R E A K I N G M A G I C P E O P L E .
12. build create W O R D C A M P C H I C A G O
S O , L E T S M A K E S O M E M A G I C …
13. build create W O R D C A M P C H I C A G O
I N Y O U R T E M P L A T E F I L E
I N Y O U R F U N C T I O N S F I L E
L E T S M A K E A N A C T I O N !
14. build create W O R D C A M P C H I C A G O
I N Y O U R F U N C T I O N S F I L E
L E T S F I LT E R T H E C O N T E N T !
( Y E A H I T ’ S T H AT S I M P L E , A N D T H I S I S L I K E
9 0 % O F W H AT I U S E F I LT E R S F O R )
15. build create W O R D C A M P C H I C A G O
L E T S G E T D A N G E R O U S
16. build create W O R D C A M P C H I C A G O
A D D I N G D A N C I N G O L D P E O P L E T O T H E PA G E I S
F U N , B U T H O W A B O U T S O M E T H I N G Y O U C A N
A C T U A L LY U S E …
Adding our JS to the
footer with the wp_footer
hook
Tying into the WP Ajax
hooks and creating our
callback
17. build create W O R D C A M P C H I C A G O
L E T S M A K E O U R O W N F I LT E R , S T Y L E A N A R R AY,
T H E N A P P LY A N O T H E R F I LT E R T O T H AT F I LT E R ,
T H E N S P I T I T A L L O U T O N T H E PA G E …
Filters, not just for strings any
more. Let’s format the hell out
of this array!
Take note of the priority
difference between the filters!
Now in our page template we
can feed some content into the
filter and get the result back.
18. build create W O R D C A M P C H I C A G O
WA N T T O A D D A S E A R C H F O R M T O Y O U R
M A I N N AV ? T H E R E ’ S A H O O K F O R T H AT.
We get the menu HTML from WordPress, and simply append our search form
and return the result.
19. build create W O R D C A M P C H I C A G O
M E O W W E ’ R E TA L K I N !
20. build create W O R D C A M P C H I C A G O
N O W Y O U ’ R E T H I N K I N G W I T H H O O K S
• Magical WP-friendly ajax requests!
• Work WITH plugins as the author
intended instead of hacking them!
• GTFO WP core files!
• Build better themes and child
themes!
• ????
• Profit!
21. build create W O R D C A M P C H I C A G O
T H A N K S F O R C O M I N G !