SlideShare a Scribd company logo
Making a Plugin Your Own
Using Actions and Filters in WordPress
Brian Hogg
brianhogg.com | @brianhogg
WordCamp Toronto 2015
brianhogg.com
Subtitle
wpontheside.com
Subtitle
Using Actions and Filters in WordPress to Make a Plugin Your Own
Actions and Filters
Actions
do_action( $identifier, [ $arg1, $arg2, ... ] )
add_action( $identifier, $function_name, [ $priority, $arg_count ] )
Actions (Example)
do_action( 'the_plugin_action' );
function handle_the_plugin_action() {
echo 'The action is happening now!';
}
add_action( 'the_plugin_action', 'handle_the_plugin_action' );
Filters
apply_filters( $identifier, $value, [ $arg1, $arg2, ... ] )
add_filter( $identifier, $function_name, [ $priority, $arg_count ] )
Filters (Example)
echo apply_filters( 'plugin_title', 'Title' );
function change_plugin_title( $title ) {
return 'New Title';
}
add_filter( 'plugin_title', 'change_plugin_title' );
Filters (Example)
echo apply_filters( 'plugin_title', 'Title' );
function change_plugin_title( $title ) {
return 'New ' . $title;
}
add_filter( 'plugin_title', 'change_plugin_title' );
How do you find what you can change in a plugin?
Search for do_action and apply_filters
The Events Calendar Plugin
•apply_filters
•442 occurrences
•do_action
•190 occurrences
How to Find The One You Need?
▪ Look at the plugin documentation (if any)
▪ Look at the code
▪ Look at the HTML output and backtrack
DEMO
The Events Calendar
▪ Message to verify location
▪ Venue -> Location
▪ Cost formatting
Can’t find the one you need?
▪ (Nicely) ask the developer of the plugin
▪ Direct contact information / website
▪ wordpress.org support forums
▪ Look for a paid support or Pro version
▪ Submit a patch
Go make plugins your own!

More Related Content

PPTX
Actions & Filters In WordPress
PPTX
#wpbar 26/3 - Förenkla WP-admin
PPTX
6. CodeIgniter copy2
PDF
Webmontag Berlin "coffee script"
PDF
Why is crud a bad idea - focus on real scenarios
KEY
jQuery - Tips And Tricks
PPTX
Wp query
PDF
정오의 데이트 for iOS 코드 정리
Actions & Filters In WordPress
#wpbar 26/3 - Förenkla WP-admin
6. CodeIgniter copy2
Webmontag Berlin "coffee script"
Why is crud a bad idea - focus on real scenarios
jQuery - Tips And Tricks
Wp query
정오의 데이트 for iOS 코드 정리

What's hot (20)

PPTX
Getting functional with elixir
PPTX
5. CodeIgniter copy1
PDF
Crafting [Better] API Clients
PDF
WordPress-Powered Portfolios
PDF
DEV Čtvrtkon #76 - Fluent Interface
KEY
Introducing CakeEntity
PPTX
Gary Gao: APIs Are Good
PDF
R版Getopt::Longを作ってみた
PDF
Feature Flags Are Flawed: Let's Make Them Better
PPTX
Алексей Плеханов: Новинки Laravel 5
KEY
Introducing CakeEntity
PPTX
Powershell function
PDF
Fat Arrow (ES6)
PDF
Getting started with ExtBase
PDF
ZCPE - PHP Conference 2015
PDF
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
DOCX
exportDisabledUsersRemoveMailbox
PPTX
Jquery ajax & form
ODP
HTML::FormHandler
PPTX
16.mysql stored procedures in laravel
Getting functional with elixir
5. CodeIgniter copy1
Crafting [Better] API Clients
WordPress-Powered Portfolios
DEV Čtvrtkon #76 - Fluent Interface
Introducing CakeEntity
Gary Gao: APIs Are Good
R版Getopt::Longを作ってみた
Feature Flags Are Flawed: Let's Make Them Better
Алексей Плеханов: Новинки Laravel 5
Introducing CakeEntity
Powershell function
Fat Arrow (ES6)
Getting started with ExtBase
ZCPE - PHP Conference 2015
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
exportDisabledUsersRemoveMailbox
Jquery ajax & form
HTML::FormHandler
16.mysql stored procedures in laravel
Ad

Viewers also liked (20)

PPTX
Ecomm 101
PDF
How I Made a Career Using WordPress Without Knowing a Line of Code
PPTX
PDF
WordCamp Toronto 2015- API Simple Talk
PDF
Help Me Help You: Practical Tips for Designers from A WordPress Developer
PDF
Wordcamp_mcglade_ux_mashups
PDF
Here Be Dragons - Debugging WordPress
PDF
You have 2 hands Toronto
PDF
A Noob's Journey to the Core
PPTX
Building and Maintaining A Remote Workforce - A Startup Story
PDF
Systematic Unit Testing
PPTX
Mystery solved pages vs posts
PDF
Community Consultation Creates Compelling Content
PDF
Speeding up your WordPress Site - WordCamp Toronto 2015
PDF
Writing Secure Code for WordPress
PDF
Best Friend || Worst Enemy: WordPress Multisite
PDF
Delightful Design with the Kano Model (WordCamp Toronto 2015)
PDF
How to use CSS3 in WordPress
PPTX
Multilingual content with WordPress
PPTX
Piecing Together the WordPress Puzzle
Ecomm 101
How I Made a Career Using WordPress Without Knowing a Line of Code
WordCamp Toronto 2015- API Simple Talk
Help Me Help You: Practical Tips for Designers from A WordPress Developer
Wordcamp_mcglade_ux_mashups
Here Be Dragons - Debugging WordPress
You have 2 hands Toronto
A Noob's Journey to the Core
Building and Maintaining A Remote Workforce - A Startup Story
Systematic Unit Testing
Mystery solved pages vs posts
Community Consultation Creates Compelling Content
Speeding up your WordPress Site - WordCamp Toronto 2015
Writing Secure Code for WordPress
Best Friend || Worst Enemy: WordPress Multisite
Delightful Design with the Kano Model (WordCamp Toronto 2015)
How to use CSS3 in WordPress
Multilingual content with WordPress
Piecing Together the WordPress Puzzle
Ad

Similar to Using Actions and Filters in WordPress to Make a Plugin Your Own (20)

PPTX
2016 WordCamp Pittsburgh - Let's Write a Plugin
PPTX
Let’s write a plugin
PDF
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
PPT
PPT
Word press Plugins by WordPress Experts
PPTX
WordPress Hooks Action & Filters
PDF
Jumping Into WordPress Plugin Programming
KEY
Actions filters
PDF
My first WordPress Plugin
PDF
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
ODP
Beginning WordPress Plugin Development
PPTX
Getting Started with WordPress Plugin Development
PPTX
Wordpress hooks
PDF
Plugin development demystified 2017
PPTX
Wordcamp2012 build your plugin
PPTX
A peek into the world of WordPress plugin development
PDF
Introduction to WordPress Hooks 2016
PDF
Bending word press to your will
PPTX
WordPress Hooks (Actions & Filters)
PDF
Write your first WordPress plugin
2016 WordCamp Pittsburgh - Let's Write a Plugin
Let’s write a plugin
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Word press Plugins by WordPress Experts
WordPress Hooks Action & Filters
Jumping Into WordPress Plugin Programming
Actions filters
My first WordPress Plugin
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Beginning WordPress Plugin Development
Getting Started with WordPress Plugin Development
Wordpress hooks
Plugin development demystified 2017
Wordcamp2012 build your plugin
A peek into the world of WordPress plugin development
Introduction to WordPress Hooks 2016
Bending word press to your will
WordPress Hooks (Actions & Filters)
Write your first WordPress plugin

More from Brian Hogg (12)

PPTX
Submitting, maintaining and growing a plugin on wp.org
PPTX
Preparing a WordPress Plugin for Translation
PPTX
Your WordPress Freelance Business Site
PDF
Things I've Learned About Creating a Premium Plugin
PDF
WordPress 4.4 and Upgrading Your Site (without the tears...)
PPTX
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
PPTX
Things I learned about Stress and Imposter Syndrome in Tech
PDF
Introduction to backbone presentation
PPT
Pricing and Marketing for Freelancers - How to?
PPTX
Introduction to test driven development
PPT
Working with Geolocation in Wordpress
PPT
Intro to Web Apps using HTML5 and Javascript
Submitting, maintaining and growing a plugin on wp.org
Preparing a WordPress Plugin for Translation
Your WordPress Freelance Business Site
Things I've Learned About Creating a Premium Plugin
WordPress 4.4 and Upgrading Your Site (without the tears...)
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Things I learned about Stress and Imposter Syndrome in Tech
Introduction to backbone presentation
Pricing and Marketing for Freelancers - How to?
Introduction to test driven development
Working with Geolocation in Wordpress
Intro to Web Apps using HTML5 and Javascript

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Modernizing your data center with Dell and AMD
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
Modernizing your data center with Dell and AMD
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.

Using Actions and Filters in WordPress to Make a Plugin Your Own

Editor's Notes

  • #6: ACTION An action is something that is fired at a specific point in time, and basically tells the WordPress world “hey! something's happening right now”. FILTER A filter allows you to modify some data or value the plugin is going to use.  You can either change parts of a value, or replace it completely, before the plugin actually uses it.
  • #7: Actions and filters are very similar in their usage. For an action, a plugin author would call do_action with a unique identifier, and optionally some extra arguments related to the action. In our code we can then create a call to add_action(), which would call a function we create when this action is fired. The first argument is the same unique identifier used in do_action, and the name of the function we want WordPress to call. Optionally we can specify the priority of our function being called relative to others who are hooking into the same action, and the number of arguments we want to pass into our function from the do_action call.
  • #9: Filters work by the plugin calling apply_filters, with a unique identifier and the default value or data the plugin wants to use. Optionally extra information can be passed in to help us decide how to change the value, such as the current post ID. In our code,
  • #15: Go forth and modify plugins using actions and filters
  • #17: So what if, after looking for documentation, looking at the code and using the search for HTML technique, you still can’t find a filter or action you can use? You can (nicely) ask the developer either directly if they provide a website or contact information, or through the support forum on the wordpress.org plugin page, for what you’re looking for. They might add it for you if it doesn’t exist already, or let you know where to find what you’re looking for. Try to be succinct and specific in your request, and remember that often plugins are maintained for free, so you might not hear back anytime soon, if ever. They may have a paid support or Pro option, which you can find by reading their plugin description or searching the web Also if possible you can try to submit a patch, or a modification to the original plugin, adding in the action or filter you want to be able to use. It’s up to the author of the plugin to include your patch or not and release it for use.
  • #18: Go forth and modify plugins using actions and filters