wordpress hooks: the right way to extend your wordpress

20
WordPress Hooks: The Right Way to Extend Your WordPress BY KAN OUIVIRACH http://www.freeiconspng.com/free-images/hook-icon-24086

Upload: kan-ouivirach-phd

Post on 21-Feb-2017

74 views

Category:

Software


2 download

TRANSCRIPT

Page 1: WordPress Hooks: The Right Way to Extend Your WordPress

WordPress Hooks:

The Right Way to Extend Your

WordPress

B Y K A N O U I V I R A C H

http://www.freeiconspng.com/free-images/hook-icon-24086

Page 2: WordPress Hooks: The Right Way to Extend Your WordPress

Research & Development Architect

KAN OUIVIRACHWho am I?

Page 4: WordPress Hooks: The Right Way to Extend Your WordPress

WHAT ARE HOOKS?

Page 5: WordPress Hooks: The Right Way to Extend Your WordPress

http://vignette1.wikia.nocookie.net/villains/images/a/a6/Captain_Hook_(Hook).jpg/revision/latest?cb=20140330214655

http://www.punchdrunksports.com/n4s-content/uploads/2015/01/Boxing-Right-Hook.jpg

??????

Page 6: WordPress Hooks: The Right Way to Extend Your WordPress

HOOKS are…• Magic

• Extend WordPress without messing with the core!

• Event-driven programming

• Actions + Filters

Page 7: WordPress Hooks: The Right Way to Extend Your WordPress

How do they work?

Page 8: WordPress Hooks: The Right Way to Extend Your WordPress

What if we want to do

something here?

WORDPRESS

<code>

</code>

Normal Flow

? ? ?

Page 9: WordPress Hooks: The Right Way to Extend Your WordPress

Hook it!

WORDPRESS

<code>

</code>

We write code.

<code>

Page 10: WordPress Hooks: The Right Way to Extend Your WordPress

WORDPRESS

<code>

</code>

<code>

New Flow!!!

2

1

3

Page 11: WordPress Hooks: The Right Way to Extend Your WordPress

Actions vs. Filters

Page 12: WordPress Hooks: The Right Way to Extend Your WordPress

File: wp-includes/plugin.php

Page 13: WordPress Hooks: The Right Way to Extend Your WordPress

File: wp-includes/plugin.php

apply_filters

Page 14: WordPress Hooks: The Right Way to Extend Your WordPress

File: wp-includes/plugin.php

do_action

Page 15: WordPress Hooks: The Right Way to Extend Your WordPress

Actions vs. Filters

do something

change something

Page 16: WordPress Hooks: The Right Way to Extend Your WordPress

File: functions.php

Add text in ‘Footer’

Page 17: WordPress Hooks: The Right Way to Extend Your WordPress

File: functions.php

Make content ‘UPPERCASE’

Page 18: WordPress Hooks: The Right Way to Extend Your WordPress

YOUR OWN HOOK!

Page 19: WordPress Hooks: The Right Way to Extend Your WordPress

Recap• Extend without modifying

• Actions vs. Filters

• Right way to extend WordPress functionality

Page 20: WordPress Hooks: The Right Way to Extend Your WordPress

Thank youhttps://github.com/zkan/wordcamp-bangkok-2017