SlideShare a Scribd company logo
Writing Extensible
Plugins in
WordPress
#WCTO2013
Imran Nathani
 What I do?:
Team lead at Shaw Media for GlobalNews.ca

About Me

 Past Experience:
For 6 yrs I have been developing print and
broadcast news websites.
Of which 4 years, I have spent exclusively
developing on WordPress VIP.
Usability

Extensibility
is not
Usability

Extensibility

 Target audience :
All WordPress users

 Target audience:
Developers

 Expectations:
Options Page,
Shortcodes,
Widgets etc.

 Expectations:

?????
What is an
extensible
plugin?

A plugin that can be
modified and extended
beyond its original purpose
by another plugin or
theme without modifying
original plugin.
Why write
an
extensible
plugin?

 Saves time
 Increases code portability
 Makes extra money $-)

 Reduces documentation
Helper
functions

 “Helps” re-use code
 “Helps” make code easier to read
Hooks
Traditional function call

What are
hooks ?
Wordpress Hook call

What are
hooks ?
Wordpress hook call ( Multiple )

What are
hooks ?
What are
hooks ?

Hooks are placeholders
for code.
Action hook

Filter hook

 Extending methods

 Extend values

 Returns nothing

 Returns a value

do_action( … )

apply_filters( … )

Types of
hooks
Action
hook

Wherever an action hook
is placed, it will execute
any code that has been
“hooked” to it.
Usage A :
do_action( ‘hook-name’ );

Action
hook
usage

Usage B:
do_action( ‘hook-name’ , $arg1, $arg2, … );
Usage C:
do_action_ref_array( ‘hook-name’ , $array );
Utility functions
 add_action(..)

Actions

 remove_action(..)
 remove_all_actions(..)
 has_action(..)
 did_action(..)
Action placements
Actions

 Before a task
 After a task
 Append mark up
Core actions
 publish_post

Actions

 save_post

 wp_head
 wp_foot
Actions
DEMO
Filter
hooks

Wherever a filter hook is
placed, it will manipulate
any value that has been
passed into with the
function “hooked” to it
Usage A :

Filter
hook
usage

$value = apply_filters( ‘hook-name’ , $value )
Usage B :

$value = apply_filters( ‘hook-name’ , $value, $args, .. )
Utility functions
 add_filter(…)

Filters

 remove_filter(…)
 remove_all_filters(...)
 has_filter(…)
 current_filter( … )
Filter placements
Filters

 Before using values
 Before value set up
 Before returning values
Core filters
Filters

 the_title
 the_excerpt

 post_link
 the_date
Filters
DEMO
Improve efficiency
Tips
&
Tricks
Improve efficiency
Tips
&
Tricks
Prefix hook names
Tips
&
Tricks
Do not over extend!

Tips
&
Tricks
Validate returns
Tips
&
Tricks
Combine Filters
Tips
&
Tricks
Combine Filters
Tips
&
Tricks
Localize scripts with Filters
Tips
&
Tricks
Localize scripts with Filters
Tips
&
Tricks
Good
reads

Wordpress Codex ( How to? )
Wordpress Core ( Why to? )
Questions?

More Related Content

PDF
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
PDF
Comment créer des hooks dans vos développements WordPress - WP Tech 2015
PDF
Write your first WordPress plugin
PDF
My first WordPress Plugin
PDF
Bending word press to your will
PDF
How I Became a WordPress Hacker
PDF
WordPress hooks - WPLDN July 2013 Meetup
ODP
Best practices in WordPress Development
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Comment créer des hooks dans vos développements WordPress - WP Tech 2015
Write your first WordPress plugin
My first WordPress Plugin
Bending word press to your will
How I Became a WordPress Hacker
WordPress hooks - WPLDN July 2013 Meetup
Best practices in WordPress Development

Similar to Writing extensible plugins (20)

PDF
jQuery UI and Plugins
PDF
Art & music vs Google App Engine
PPTX
Android development with Scala and SBT
PPT
JavaOne TS-5098 Groovy SwingBuilder
PDF
Behaviour driven infrastructure
PDF
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
PDF
Symfony tips and tricks
KEY
From Dev to DevOps - Apache Barcamp Spain 2011
PDF
Anatomy of an Addon Ecosystem - EmberConf 2019
PDF
Attacking Pipelines--Security meets Continuous Delivery
PPTX
Working with AngularJS
PDF
purely_functional_play_framework_application
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
PPT
Working Effectively With Legacy Code
PDF
Python in the land of serverless
PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
KEY
Open Atrium (DrupalCon Paris 2009, Day 3)
PDF
Leave your jQuery behind
PDF
Android Jumpstart Jfokus
PDF
Building Mobile Friendly APIs in Rails
jQuery UI and Plugins
Art & music vs Google App Engine
Android development with Scala and SBT
JavaOne TS-5098 Groovy SwingBuilder
Behaviour driven infrastructure
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
Symfony tips and tricks
From Dev to DevOps - Apache Barcamp Spain 2011
Anatomy of an Addon Ecosystem - EmberConf 2019
Attacking Pipelines--Security meets Continuous Delivery
Working with AngularJS
purely_functional_play_framework_application
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Working Effectively With Legacy Code
Python in the land of serverless
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Open Atrium (DrupalCon Paris 2009, Day 3)
Leave your jQuery behind
Android Jumpstart Jfokus
Building Mobile Friendly APIs in Rails
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
KodekX | Application Modernization Development
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
Mobile App Security Testing_ A Comprehensive Guide.pdf
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KodekX | Application Modernization Development
Ad

Writing extensible plugins

Editor's Notes

  • #6: => What are the traditional methods to extend code?
  • #9: Isn’t this how functions work?
  • #10: Isn’t this how functions work?
  • #11: Isn’t this how functions work?