SlideShare una empresa de Scribd logo
1 de 35
5 W's of Hookin'
Nowell VanHoesen
@NowellVanHoesen
about.me/NowellVanHoesen
Hookin' Overview
What are Hooks
Who hooks
Why hook
Where are they
When to hook
Examples
@NowellVanHoesen5 W's of Hookin'
What are hooks?
A specific place/time in WordPress code
execution to add functionality or change data.
@NowellVanHoesen5 W's of Hookin'
What are hooks?
A specific place/time in WordPress code
execution to add functionality or change data.
Types:
– Action: add functionality at a specific point
when an event happens or is about to
happen.
@NowellVanHoesen5 W's of Hookin'
What are hooks?
A specific place/time in WordPress code
execution to add functionality or change data.
Types:
– Action: add functionality at a specific point
when an event happens or is about to
happen.
– Filter: modify data before some event
( save, display )
@NowellVanHoesen5 W's of Hookin'
Who hooks?
@NowellVanHoesen5 W's of Hookin'
Who hooks?
Any one who wants to add custom code to
change how WordPress behaves or modify
what is output to the browser.
@NowellVanHoesen5 W's of Hookin'
Who hooks?
Any one who wants to add custom code to
change how WordPress behaves or modify
what is output to the browser.
Anyone who wants to allow others to build on
to their plugin or theme.
@NowellVanHoesen5 W's of Hookin'
Why
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
● Tweak
functionality/output
to better fit your
needs
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
● Tweak
functionality/output
to better fit your
needs
● Maintain your
customizations when
updating
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
● Tweak
functionality/output
to better fit your
needs
● Maintain your
customizations when
updating
create hooks
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
● Tweak
functionality/output
to better fit your
needs
● Maintain your
customizations when
updating
create hooks
● Allow others to add
functionality
@NowellVanHoesen5 W's of Hookin'
Why
use hooks
● Tweak
functionality/output
to better fit your
needs
● Maintain your
customizations when
updating
create hooks
● Allow others to add
functionality
● Allow others to filter
output from your
plugin/theme
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
can I create them
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
can I create them
● Themes
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
can I create them
● Themes
● Plugins
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
can I create them
● Themes
● Plugins
● WordPress core
@NowellVanHoesen5 W's of Hookin'
Where...
can I find them
● WordPress core
● Themes
● Plugins
can I create them
● Themes
● Plugins
● WordPress core
@NowellVanHoesen5 W's of Hookin'
How?
Actions Filters
@NowellVanHoesen5 W's of Hookin'
How?
Actions
● add_action( t, f, p, a )
Filters
● add_filter( t, f, p, a )
@NowellVanHoesen5 W's of Hookin'
t = tag f = function p = priority a = # args
How?
Actions
● add_action( t, f, p, a )
● remove_action( t, f,
p, a )
Filters
● add_filter( t, f, p, a )
● remove_filter( t, f, p,
a )
@NowellVanHoesen5 W's of Hookin'
t = tag f = function p = priority a = # args
How?
Actions
● add_action( t, f, p, a )
● remove_action( t, f,
p, a )
● do_action( t, f, p, a )
Filters
● add_filter( t, f, p, a )
● remove_filter( t, f, p,
a )
● apply_filters( t, f, p,
a )
@NowellVanHoesen5 W's of Hookin'
t = tag f = function p = priority a = # args
How?
Actions
● add_action( t, f, p, a )
● remove_action( t, f,
p, a )
● do_action( t, f, p, a )
Filters
● add_filter( t, f, p, a )
● remove_filter( t, f, p,
a )
● apply_filters( t, f, p,
a )
@NowellVanHoesen5 W's of Hookin'
http://codex.wordpress.org/Plugin_API
t = tag f = function p = priority a = # args
Action hook example 1
// wp_enqueue_scripts action
add_action( 'wp_enqueue_scripts', 'nv_added_styles' );
function nv_added_styles() {
if ( !is_admin() ) {
wp_register_style(
'nv-ie-fix',
get_bloginfo( 'stylesheet_directory' ) . '/ie.css',
false
);
$GLOBALS['wp_styles']->add_data(
'nv-ie-fix',
'conditional',
'lte IE 8'
);
wp_enqueue_style( 'nv-ie-fix' );
}
}
@NowellVanHoesen5 W's of Hookin'
Action hook example 2
add_action( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
global $wp_the_query;
if( $wp_the_query === $query && $query->is_home() ) {
add_filter( 'posts_where' , 'posts_where' );
$category_id = get_cat_ID( 'Scribblings' );
$query->set( 'cat', $category_id );
} else if ( is_archive() && is_date() && !is_category()) {
if ( !isset( $query->query_vars['post_type'] ) ) {
$query->set( 'post_type', array( 'post', 'myoldhouse', 'snapshots' ) );
$query->set( 'posts_per_page', -1 );
}
}
}
function posts_where( $where ) {
$where = " AND ( ( wp_term_relationships.term_taxonomy_id IN (1) AND wp_posts.post_type =
'post' ) OR ( wp_posts.post_type IN ('myoldhouse', 'snapshots') ) ) AND (wp_posts.post_status =
'publish' OR wp_posts.post_status = 'private')";
return $where;
}
@NowellVanHoesen5 W's of Hookin'
Filter hook examples
add_filter( 'the_title', 'nv_the_title', 10, 2 );
function nv_the_title( $title, $id ) {
if ( !is_admin() ) {
$title = 'WCCbus - ' . $title;
}
return $title;
}
// what core runs
return apply_filters( 'the_title', $title, $id );
add_filter( 'enter_title_here', 'change_default_post_title', 10, 2 );
function change_default_post_title( $text, $post ) {
if ( 'post' == get_post_type( $post ) ) {
return $text . “ - Required”;
}
}
@NowellVanHoesen5 W's of Hookin'
Time to go live...
@NowellVanHoesen5 W's of Hookin'
Time to go live...
@NowellVanHoesen5 W's of Hookin'
Resources
@NowellVanHoesen5 W's of Hookin'
Plugin API on the codex
- http://codex.wordpress.org/Plugin_API
Drew Jaynes – Filter of the Day: Three filters a day for 365
days
- http://fotd.werdswords.com/

Más contenido relacionado

La actualidad más candente

RxJS - The Basics & The Future
RxJS - The Basics & The FutureRxJS - The Basics & The Future
RxJS - The Basics & The FutureTracy Lee
 
Dev with github enterprise
Dev with github enterpriseDev with github enterprise
Dev with github enterpriseHiroshi Wada
 
Michael King - The Thin Line Between Seth Godin & Neil Strauss
Michael King - The Thin Line Between Seth Godin & Neil StraussMichael King - The Thin Line Between Seth Godin & Neil Strauss
Michael King - The Thin Line Between Seth Godin & Neil StraussWebrazzi
 
Functions.php - It's Not Just For Developers
Functions.php - It's Not Just For DevelopersFunctions.php - It's Not Just For Developers
Functions.php - It's Not Just For DevelopersEric Mann
 
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 MinutesUsing Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 MinutesTracy Lee
 
Building Rackspace Cloud Monitoring
Building Rackspace Cloud MonitoringBuilding Rackspace Cloud Monitoring
Building Rackspace Cloud Monitoringgdusbabek
 
Interns What Is DevOps
Interns What Is DevOpsInterns What Is DevOps
Interns What Is DevOpsAaron Blythe
 
Telco Cloud How operators are using the Cloud to unlock the core network and ...
Telco Cloud How operators are using the Cloud to unlock the core network and ...Telco Cloud How operators are using the Cloud to unlock the core network and ...
Telco Cloud How operators are using the Cloud to unlock the core network and ...Alan Quayle
 
ESADE - Plugged-In Management
ESADE - Plugged-In ManagementESADE - Plugged-In Management
ESADE - Plugged-In ManagementTerri Griffith
 
DevOps 101 for data professionals
DevOps 101 for data professionalsDevOps 101 for data professionals
DevOps 101 for data professionalsAlex Yates
 
Content sourcing with Red Bull
Content sourcing with Red BullContent sourcing with Red Bull
Content sourcing with Red BullMichael Kurz
 
Contributing to Impala
Contributing to ImpalaContributing to Impala
Contributing to ImpalaCloudera, Inc.
 
Why you should add React to your Rails application now!
Why you should add React to your Rails application now!Why you should add React to your Rails application now!
Why you should add React to your Rails application now!David Roberts
 
Open Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering TeamsOpen Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering TeamsAll Things Open
 

La actualidad más candente (16)

Drupal DOMinate
Drupal DOMinateDrupal DOMinate
Drupal DOMinate
 
RxJS - The Basics & The Future
RxJS - The Basics & The FutureRxJS - The Basics & The Future
RxJS - The Basics & The Future
 
Dev with github enterprise
Dev with github enterpriseDev with github enterprise
Dev with github enterprise
 
Michael King - The Thin Line Between Seth Godin & Neil Strauss
Michael King - The Thin Line Between Seth Godin & Neil StraussMichael King - The Thin Line Between Seth Godin & Neil Strauss
Michael King - The Thin Line Between Seth Godin & Neil Strauss
 
Functions.php - It's Not Just For Developers
Functions.php - It's Not Just For DevelopersFunctions.php - It's Not Just For Developers
Functions.php - It's Not Just For Developers
 
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 MinutesUsing Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
 
Building Rackspace Cloud Monitoring
Building Rackspace Cloud MonitoringBuilding Rackspace Cloud Monitoring
Building Rackspace Cloud Monitoring
 
Interns What Is DevOps
Interns What Is DevOpsInterns What Is DevOps
Interns What Is DevOps
 
Telco Cloud How operators are using the Cloud to unlock the core network and ...
Telco Cloud How operators are using the Cloud to unlock the core network and ...Telco Cloud How operators are using the Cloud to unlock the core network and ...
Telco Cloud How operators are using the Cloud to unlock the core network and ...
 
Refactoring a web application with Python
Refactoring a web application with PythonRefactoring a web application with Python
Refactoring a web application with Python
 
ESADE - Plugged-In Management
ESADE - Plugged-In ManagementESADE - Plugged-In Management
ESADE - Plugged-In Management
 
DevOps 101 for data professionals
DevOps 101 for data professionalsDevOps 101 for data professionals
DevOps 101 for data professionals
 
Content sourcing with Red Bull
Content sourcing with Red BullContent sourcing with Red Bull
Content sourcing with Red Bull
 
Contributing to Impala
Contributing to ImpalaContributing to Impala
Contributing to Impala
 
Why you should add React to your Rails application now!
Why you should add React to your Rails application now!Why you should add React to your Rails application now!
Why you should add React to your Rails application now!
 
Open Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering TeamsOpen Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering Teams
 

Similar a 5 W's of Hookin'

Hooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp ColumbusHooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp ColumbusShawn Hooper
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Ian Wilson
 
WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)MuhammadKashif596
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...WordCamp Sydney
 
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Alessandro Nadalin
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPresstopher1kenobe
 
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02sos informatique
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!David Wolfpaw
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
Master the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexRyan Weaver
 
WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)Rodolfo Melogli
 
Theming Wordpress with Adobe
Theming Wordpress with AdobeTheming Wordpress with Adobe
Theming Wordpress with AdobeGrace Solivan
 
Developing client themes for theme review for WordCamp Edmonton
Developing client themes for theme review for WordCamp EdmontonDeveloping client themes for theme review for WordCamp Edmonton
Developing client themes for theme review for WordCamp EdmontonCurtis McHale
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designerselliotjaystocks
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 

Similar a 5 W's of Hookin' (20)

Hooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp ColumbusHooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp Columbus
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)
 
Cain & Obenland — Episode 4
Cain & Obenland — Episode 4Cain & Obenland — Episode 4
Cain & Obenland — Episode 4
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
 
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Master the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and Silex
 
WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)WooCommerce Customization Masterclass (WordCamp Dublin 2017)
WooCommerce Customization Masterclass (WordCamp Dublin 2017)
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
Theming Wordpress with Adobe
Theming Wordpress with AdobeTheming Wordpress with Adobe
Theming Wordpress with Adobe
 
Developing client themes for theme review for WordCamp Edmonton
Developing client themes for theme review for WordCamp EdmontonDeveloping client themes for theme review for WordCamp Edmonton
Developing client themes for theme review for WordCamp Edmonton
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 

Último

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Último (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

5 W's of Hookin'

  • 1. 5 W's of Hookin' Nowell VanHoesen @NowellVanHoesen about.me/NowellVanHoesen
  • 2. Hookin' Overview What are Hooks Who hooks Why hook Where are they When to hook Examples @NowellVanHoesen5 W's of Hookin'
  • 3. What are hooks? A specific place/time in WordPress code execution to add functionality or change data. @NowellVanHoesen5 W's of Hookin'
  • 4. What are hooks? A specific place/time in WordPress code execution to add functionality or change data. Types: – Action: add functionality at a specific point when an event happens or is about to happen. @NowellVanHoesen5 W's of Hookin'
  • 5. What are hooks? A specific place/time in WordPress code execution to add functionality or change data. Types: – Action: add functionality at a specific point when an event happens or is about to happen. – Filter: modify data before some event ( save, display ) @NowellVanHoesen5 W's of Hookin'
  • 7. Who hooks? Any one who wants to add custom code to change how WordPress behaves or modify what is output to the browser. @NowellVanHoesen5 W's of Hookin'
  • 8. Who hooks? Any one who wants to add custom code to change how WordPress behaves or modify what is output to the browser. Anyone who wants to allow others to build on to their plugin or theme. @NowellVanHoesen5 W's of Hookin'
  • 11. Why use hooks ● Tweak functionality/output to better fit your needs @NowellVanHoesen5 W's of Hookin'
  • 12. Why use hooks ● Tweak functionality/output to better fit your needs ● Maintain your customizations when updating @NowellVanHoesen5 W's of Hookin'
  • 13. Why use hooks ● Tweak functionality/output to better fit your needs ● Maintain your customizations when updating create hooks @NowellVanHoesen5 W's of Hookin'
  • 14. Why use hooks ● Tweak functionality/output to better fit your needs ● Maintain your customizations when updating create hooks ● Allow others to add functionality @NowellVanHoesen5 W's of Hookin'
  • 15. Why use hooks ● Tweak functionality/output to better fit your needs ● Maintain your customizations when updating create hooks ● Allow others to add functionality ● Allow others to filter output from your plugin/theme @NowellVanHoesen5 W's of Hookin'
  • 16. Where... can I find them @NowellVanHoesen5 W's of Hookin'
  • 17. Where... can I find them ● WordPress core @NowellVanHoesen5 W's of Hookin'
  • 18. Where... can I find them ● WordPress core ● Themes @NowellVanHoesen5 W's of Hookin'
  • 19. Where... can I find them ● WordPress core ● Themes ● Plugins @NowellVanHoesen5 W's of Hookin'
  • 20. Where... can I find them ● WordPress core ● Themes ● Plugins can I create them @NowellVanHoesen5 W's of Hookin'
  • 21. Where... can I find them ● WordPress core ● Themes ● Plugins can I create them ● Themes @NowellVanHoesen5 W's of Hookin'
  • 22. Where... can I find them ● WordPress core ● Themes ● Plugins can I create them ● Themes ● Plugins @NowellVanHoesen5 W's of Hookin'
  • 23. Where... can I find them ● WordPress core ● Themes ● Plugins can I create them ● Themes ● Plugins ● WordPress core @NowellVanHoesen5 W's of Hookin'
  • 24. Where... can I find them ● WordPress core ● Themes ● Plugins can I create them ● Themes ● Plugins ● WordPress core @NowellVanHoesen5 W's of Hookin'
  • 26. How? Actions ● add_action( t, f, p, a ) Filters ● add_filter( t, f, p, a ) @NowellVanHoesen5 W's of Hookin' t = tag f = function p = priority a = # args
  • 27. How? Actions ● add_action( t, f, p, a ) ● remove_action( t, f, p, a ) Filters ● add_filter( t, f, p, a ) ● remove_filter( t, f, p, a ) @NowellVanHoesen5 W's of Hookin' t = tag f = function p = priority a = # args
  • 28. How? Actions ● add_action( t, f, p, a ) ● remove_action( t, f, p, a ) ● do_action( t, f, p, a ) Filters ● add_filter( t, f, p, a ) ● remove_filter( t, f, p, a ) ● apply_filters( t, f, p, a ) @NowellVanHoesen5 W's of Hookin' t = tag f = function p = priority a = # args
  • 29. How? Actions ● add_action( t, f, p, a ) ● remove_action( t, f, p, a ) ● do_action( t, f, p, a ) Filters ● add_filter( t, f, p, a ) ● remove_filter( t, f, p, a ) ● apply_filters( t, f, p, a ) @NowellVanHoesen5 W's of Hookin' http://codex.wordpress.org/Plugin_API t = tag f = function p = priority a = # args
  • 30. Action hook example 1 // wp_enqueue_scripts action add_action( 'wp_enqueue_scripts', 'nv_added_styles' ); function nv_added_styles() { if ( !is_admin() ) { wp_register_style( 'nv-ie-fix', get_bloginfo( 'stylesheet_directory' ) . '/ie.css', false ); $GLOBALS['wp_styles']->add_data( 'nv-ie-fix', 'conditional', 'lte IE 8' ); wp_enqueue_style( 'nv-ie-fix' ); } } @NowellVanHoesen5 W's of Hookin'
  • 31. Action hook example 2 add_action( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { global $wp_the_query; if( $wp_the_query === $query && $query->is_home() ) { add_filter( 'posts_where' , 'posts_where' ); $category_id = get_cat_ID( 'Scribblings' ); $query->set( 'cat', $category_id ); } else if ( is_archive() && is_date() && !is_category()) { if ( !isset( $query->query_vars['post_type'] ) ) { $query->set( 'post_type', array( 'post', 'myoldhouse', 'snapshots' ) ); $query->set( 'posts_per_page', -1 ); } } } function posts_where( $where ) { $where = " AND ( ( wp_term_relationships.term_taxonomy_id IN (1) AND wp_posts.post_type = 'post' ) OR ( wp_posts.post_type IN ('myoldhouse', 'snapshots') ) ) AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')"; return $where; } @NowellVanHoesen5 W's of Hookin'
  • 32. Filter hook examples add_filter( 'the_title', 'nv_the_title', 10, 2 ); function nv_the_title( $title, $id ) { if ( !is_admin() ) { $title = 'WCCbus - ' . $title; } return $title; } // what core runs return apply_filters( 'the_title', $title, $id ); add_filter( 'enter_title_here', 'change_default_post_title', 10, 2 ); function change_default_post_title( $text, $post ) { if ( 'post' == get_post_type( $post ) ) { return $text . “ - Required”; } } @NowellVanHoesen5 W's of Hookin'
  • 33. Time to go live... @NowellVanHoesen5 W's of Hookin'
  • 34. Time to go live... @NowellVanHoesen5 W's of Hookin'
  • 35. Resources @NowellVanHoesen5 W's of Hookin' Plugin API on the codex - http://codex.wordpress.org/Plugin_API Drew Jaynes – Filter of the Day: Three filters a day for 365 days - http://fotd.werdswords.com/