SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
How I Became a WordPress
Hacker
Mike Zielonka
@mikezielonka
Co-Founder and Director of Web Strategy
At Tuna Traffic
Loves Pizza, Dogs, More Pizza and Coffee
I Am Mike Zielonka
What We’ll Cover
● Why the struggle is part of the journey
● The basics of using Actions & Filters
● How to make a plugin for your Hooks
Successful WordPress Hackers Can...
Customize WordPress Themes and Plugins
without writing a lot of code.
The Struggle Is…
● PHP is scary
● Making your own plugin is scary
● PHP is very scary
● You just never have the options you need
My Journey
2011 Mike “The SEO”
2012 Mike “Frameworks”
2013 Mike “The Hacker”
2014 Mike “Expert Generalist”
Whats a Hook According to the Codex
“Hooks are specified, by the developer, in
Actions and Filters. “
“In technical and strict terms: a Hook is an event, i.e. event as understood
by Observer pattern, invoked by the do_action() or apply_filters() call that
afterwards triggers all the action or filter functions, previously hooked to
that event using add_action() or add_filter(), respectively.”
Where do Hooks Live
Generally speaking, you have 3 different
places where “hooks” live.
● Core
● Themes
● Plugins
Allows you to “do something” to insert
something at a “checkpoint”.
Action Defined
Action Example
add_action( ‘wp_head’, ‘wc_your_function_name’ );
function wc_your_function_name() {
?>
<!--hi people-->
<?php
}
add_action
add_action( ‘wp_head’, ‘wc_your_function_name’ );
Where You Hook In What To Add
Adding What You Want (Writing a Function)
function wc_your_function_name() {
?>
<!--hi people-->
<?php
}
Your function name
PHP On and Off
Your HTML
Real Life Example
//Adding A Credit Link to TwentyFourteen
add_action( 'twentyfourteen_credits' , 'mz_site_credits'
);
function mz_site_credits() {
echo "<a href='http://iammike.co' title='mike
zielonka'>Designed by Mike Zielonka</a>";
}
Allows you to “filter the result” and return
something different at a “fancy checkpoint”.
Filter
Filter Example
add_filter( ‘wp_title’,
‘wc_your_function_filter_name’, 10, 2 );
function wc_your_function_filter_name($title, $sep)
{
$name = ‘My Site is Called ’;
$title .= $sep . ' ' . $name;
return $title;
}
add_filter
add_filter( ‘wp_title’,‘wc_your_function_filter_name’, 10,
2 );
Where You Hook In What To Add
Priority
Accepted Arguments
Returning What You Want (Writing a Function)
function wc_your_function_filter_name($title, $sep)
{
$name = ‘My Site is Called ’;
$title .= $sep . ' ' . $name;
return $title;
}
Your function name
Return your
changes
Arguments
Real Life Example
//Adding a Phrase the Site Title
add_filter( 'wp_title', 'wc_your_function_filter_name', 10, 2 );
function wc_your_function_filter_name($title, $sep) {
$name = 'My Site is Called ';
$title .= $sep . ' ' . $name;
return $title;
}
Where To Put Your Hooks
● Functions.php of your theme
○ Preferably in a child theme
● Plugin
Adding Hooks To A Plugin
Add Opening PHP Tag and Add A Plugin Header
<?php
/*
Plugin Name: Mike's Sample Plugin
Plugin URI:
Description: Adds some sample hooks.
Author: Mike Zielonka
Version: 1.0
Author URI: http://iammike.co
Text Domain: mz-sample-plugin
*/
Putting It All Together
Basic Rookie Tips
● Namespace your functions to avoid
conflicts. ie: mz_function
● Do not start functions with numbers.
● Always take back ups.
● Learn more about the PHP function
function_exists() to prevent headaches
when switching themes and plugins
Helpful Tools
For Hooking Efficiently
Google
Debug Bar w/ Debug Bar Actions and Filters Addon
Searching for Actions in Sublime Text 3
Follow Me On Twitter
@mikezielonka
Thank You

Más contenido relacionado

La actualidad más candente

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web frameworktaggg
 
Web Automation Testing Using Selenium
Web Automation Testing Using SeleniumWeb Automation Testing Using Selenium
Web Automation Testing Using SeleniumPete Chen
 
Javascript #8 : événements
Javascript #8 : événementsJavascript #8 : événements
Javascript #8 : événementsJean Michel
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with GaelykChoong Ping Teo
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tCosimo Streppone
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Anatoly Sharifulin
 
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django applicationDjangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django applicationMasashi Shibata
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklum Ukraine
 
Service workers and the role they play in modern day web apps
Service workers and the role they play in modern day web appsService workers and the role they play in modern day web apps
Service workers and the role they play in modern day web appsMukul Jain
 
PowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking GlassPowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking GlassBrian Caauwe
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone frameworkfrontendne
 

La actualidad más candente (20)

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Web Automation Testing Using Selenium
Web Automation Testing Using SeleniumWeb Automation Testing Using Selenium
Web Automation Testing Using Selenium
 
Vue.js for beginners
Vue.js for beginnersVue.js for beginners
Vue.js for beginners
 
Built in filters
Built in filtersBuilt in filters
Built in filters
 
Javascript #8 : événements
Javascript #8 : événementsJavascript #8 : événements
Javascript #8 : événements
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
A Look at ASP.NET MVC 4
A Look at ASP.NET MVC 4A Look at ASP.NET MVC 4
A Look at ASP.NET MVC 4
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Mixpanel
MixpanelMixpanel
Mixpanel
 
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django applicationDjangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django application
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Web Os Hands On
Web Os Hands OnWeb Os Hands On
Web Os Hands On
 
Service workers and the role they play in modern day web apps
Service workers and the role they play in modern day web appsService workers and the role they play in modern day web apps
Service workers and the role they play in modern day web apps
 
PowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking GlassPowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking Glass
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone framework
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 

Similar a How I Became a WordPress Hacker

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingDougal Campbell
 
WordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoWordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoJoseph Dolson
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress DevelopmentAdam Tomat
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2Josh Lee
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress DevelopmentMindfire Solutions
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Cogapp
 
Manipulating Magento - Mage Titans Italy 2018
Manipulating Magento - Mage Titans Italy 2018Manipulating Magento - Mage Titans Italy 2018
Manipulating Magento - Mage Titans Italy 2018Joke Puts
 
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
 
T3CON13: Web application development using Behaviour Driven Development
T3CON13: Web application development using Behaviour Driven DevelopmentT3CON13: Web application development using Behaviour Driven Development
T3CON13: Web application development using Behaviour Driven Developmentmhelmich
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchKaty Slemon
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Atlassian
 
WordPress Hooks Action & Filters
WordPress Hooks Action & FiltersWordPress Hooks Action & Filters
WordPress Hooks Action & FiltersNirav Mehta
 

Similar a How I Became a WordPress Hacker (20)

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Actions filters
Actions filtersActions filters
Actions filters
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
WordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoWordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp Chicago
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 
WCLA12 JavaScript
WCLA12 JavaScriptWCLA12 JavaScript
WCLA12 JavaScript
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Manipulating Magento - Mage Titans Italy 2018
Manipulating Magento - Mage Titans Italy 2018Manipulating Magento - Mage Titans Italy 2018
Manipulating Magento - Mage Titans Italy 2018
 
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...
 
T3CON13: Web application development using Behaviour Driven Development
T3CON13: Web application development using Behaviour Driven DevelopmentT3CON13: Web application development using Behaviour Driven Development
T3CON13: Web application development using Behaviour Driven Development
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
 
WordPress Hooks Action & Filters
WordPress Hooks Action & FiltersWordPress Hooks Action & Filters
WordPress Hooks Action & Filters
 

How I Became a WordPress Hacker

  • 1. How I Became a WordPress Hacker Mike Zielonka @mikezielonka
  • 2. Co-Founder and Director of Web Strategy At Tuna Traffic Loves Pizza, Dogs, More Pizza and Coffee I Am Mike Zielonka
  • 3. What We’ll Cover ● Why the struggle is part of the journey ● The basics of using Actions & Filters ● How to make a plugin for your Hooks
  • 4. Successful WordPress Hackers Can... Customize WordPress Themes and Plugins without writing a lot of code.
  • 5. The Struggle Is… ● PHP is scary ● Making your own plugin is scary ● PHP is very scary ● You just never have the options you need
  • 6. My Journey 2011 Mike “The SEO” 2012 Mike “Frameworks” 2013 Mike “The Hacker” 2014 Mike “Expert Generalist”
  • 7. Whats a Hook According to the Codex “Hooks are specified, by the developer, in Actions and Filters. “ “In technical and strict terms: a Hook is an event, i.e. event as understood by Observer pattern, invoked by the do_action() or apply_filters() call that afterwards triggers all the action or filter functions, previously hooked to that event using add_action() or add_filter(), respectively.”
  • 8. Where do Hooks Live Generally speaking, you have 3 different places where “hooks” live. ● Core ● Themes ● Plugins
  • 9. Allows you to “do something” to insert something at a “checkpoint”. Action Defined
  • 10. Action Example add_action( ‘wp_head’, ‘wc_your_function_name’ ); function wc_your_function_name() { ?> <!--hi people--> <?php }
  • 12. Adding What You Want (Writing a Function) function wc_your_function_name() { ?> <!--hi people--> <?php } Your function name PHP On and Off Your HTML
  • 13. Real Life Example //Adding A Credit Link to TwentyFourteen add_action( 'twentyfourteen_credits' , 'mz_site_credits' ); function mz_site_credits() { echo "<a href='http://iammike.co' title='mike zielonka'>Designed by Mike Zielonka</a>"; }
  • 14. Allows you to “filter the result” and return something different at a “fancy checkpoint”. Filter
  • 15. Filter Example add_filter( ‘wp_title’, ‘wc_your_function_filter_name’, 10, 2 ); function wc_your_function_filter_name($title, $sep) { $name = ‘My Site is Called ’; $title .= $sep . ' ' . $name; return $title; }
  • 16. add_filter add_filter( ‘wp_title’,‘wc_your_function_filter_name’, 10, 2 ); Where You Hook In What To Add Priority Accepted Arguments
  • 17. Returning What You Want (Writing a Function) function wc_your_function_filter_name($title, $sep) { $name = ‘My Site is Called ’; $title .= $sep . ' ' . $name; return $title; } Your function name Return your changes Arguments
  • 18. Real Life Example //Adding a Phrase the Site Title add_filter( 'wp_title', 'wc_your_function_filter_name', 10, 2 ); function wc_your_function_filter_name($title, $sep) { $name = 'My Site is Called '; $title .= $sep . ' ' . $name; return $title; }
  • 19. Where To Put Your Hooks ● Functions.php of your theme ○ Preferably in a child theme ● Plugin
  • 20. Adding Hooks To A Plugin Add Opening PHP Tag and Add A Plugin Header <?php /* Plugin Name: Mike's Sample Plugin Plugin URI: Description: Adds some sample hooks. Author: Mike Zielonka Version: 1.0 Author URI: http://iammike.co Text Domain: mz-sample-plugin */
  • 21. Putting It All Together
  • 22. Basic Rookie Tips ● Namespace your functions to avoid conflicts. ie: mz_function ● Do not start functions with numbers. ● Always take back ups. ● Learn more about the PHP function function_exists() to prevent headaches when switching themes and plugins
  • 25. Debug Bar w/ Debug Bar Actions and Filters Addon
  • 26. Searching for Actions in Sublime Text 3
  • 27. Follow Me On Twitter @mikezielonka Thank You