SlideShare a Scribd company logo
WordPress Plugin Development for Beginners
John P. Bloch
Senior Web Developer
Avendi Media, Inc.
http://www.johnpbloch.com/
@johnpbloch
What Are Plugins?
 The stupid answer:
 Anything you want*
 *theoretically, at least
 The useful answer:
 Non-essential and elective aspects of any given
WordPress installation
Wait a Minute...
Aren't plugins just
extensions of
WordPress? Don't
they just add
functionality that isn't
there?
Plugins are Part of WordPress
 Plugins have primacy of place
 Plugins interact with WordPress in the same
way WordPress interacts with itself
An Example Plugin
How Do Plugins Work?
 Almost all plugin use hooks. There are two
kinds of hooks:
 Actions
 Filters
 What's the difference?
 Filters expect you to return something, and...
 … that's it!
 Hooks let you tell WordPress to execute a
function when the specified hook fires
How To Use Hooks
 Filters:
 <?php add_filter( 'filter_name', 'function_name' ); ?>
 Actions:
 <?php add_action( 'action_name', 'func_name' ); ?>
 Both functions take two optional arguments:
 Priority
 Accepted Arguments
How To Fire Hooks
 To fire an action:
 <?php do_action( 'action_name' ); ?>
 This fires all functions hooked into that action
 To fire a filter:
 <?php apply_filters( 'filter_name', 'Filter value' ); ?>
 The 'Filter value' will be the first argument of each
hooked function
 apply_filters will return the filtered input
How Does Priority Work?
Actions and filters are
executed in the order
they are added. So
this code will echo:
First
Second
Third
How Does Priority Work?
Priority changes this
order. Actions and
filters have a default
priority of 10. Using a
lower number gives it
higher priority. This
code ouputs:
Third
First
Second
Accepted Arguments
 Accepted arguments allows you to specify how
many arguments to send to a hooked function
 Defaults to 1 for both actions and filters
 The following would output:
Don't mention Joomla
Don't mention
Some Common Hooks
 Actions
 init
 template_redirect
 admin_init
 after_setup_theme
 wp_loaded
 wp_head
 wp_footer
 admin_menu
 Filters
 the_content
 the_title
 wp_title
 template_include
 body_class
 post_class
But Wait! There's More!
 One more way to hook into WordPress is
through shortcodes
 Shortcodes are inserted into a post or page
from the editor; WordPress replaces the
shortcode tags with dynamically generated
content
 Shortcodes are kind of like HTML:
 [foo bar='bar']
 [foo bar='bar']Some Content[/foo]
How to Add a Shortcode
 Shortcodes must be registered:
 <?php add_shortcode( 'tag_name', 'function_name' ); ?>
 Shortcode handlers take two optional
arguments:
 Arguments: an array of arguments from the
shortcode
 Content: the content (if any) of the shortcode
 Shortcode handlers should return, not echo,
their content
An Example of a Shortcode
Developer Toolbox
 Local development environment
 LAMPP Stack (XAMPP – http://apachefriends.org)
 Subversion
 Windows: TortoiseSVN or Cygwin
 Everything else: CLI
 Text Editor
 FTP client
 Mac: Transmit
 SSH Client
 Windows: Putty
 Reference
 PHPXref (http://www.phpxref.com)
WordPress Developer Toolbox
 Official Support Channels
 WordPress Codex (http://codex.wordpress.org/)
 WordPress Forums (http://wordpress.org/support/)
 IRC Channel #wordpress (chat.freenode.net)
 Mailing Lists (sort of) (http://codex.wordpress.org/Mailing_Lists)
 Unofficial Support Channels
 WordPress Answers (http://wordpress.stackexchange.com/)
 WordPress Docs (http://wpdocs.labs.thedextrousweb.com/)
 Alot of Books
Just Because
Adding Your Plugin to the Directory
 http://wordpress.org/extend/plugins/add/
 Answer a few questions
 Name – Very important! This will determine the
name of the directory your plugin creates
 Description
 Plugin URL (optional)
 … And wait!
What is SVN?
SVN, or Subversion, is a version control program.
Others include Git and Mercurial. Subversion is
used for core WordPress development/distribution
and official plugin development/distribution.
Once you have your repository, anybody in the
world can check it out. Only you* can check files
into it.
*Technically, Nacin and some others have global plugin repo commit
access. #blamenacin
How to Use SVN
 If you are on windows and use TortoiseSVN,
just follow these next steps substituting ”Click X
menu item” for ”Execute X command”
 Go to the directory into which you'd like the
repo to go:
 ~$ cd Documents/svn
 Check out your repository for the first time:
 ~$ svn co http://plugins.svn.wordpress.org/custom-post-permalinks/ custom-post-permalinks
 Edit to your heart's content
How to Use SVN
 When you're done making changes (or reach a
good stopping point), commit your changes:
 ~$ svn ci -m 'This is a description of the commit!'
 … Tada!
Some Other Notes on SVN
 Updating your plugin
 Tagging vs. Stable Trunk
 Branching
 Adding committers (and other admin tools)
Further Reading
 Core.
 Core.
 Core.
 Seriously. Just read core's runtime execution.
 Line by line.
Now Let's Get Down to Business!
Time to switch gears, open VIM,
and write a plugin!

More Related Content

What's hot

The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
Dougal Campbell
 
Wordcamp2012 build your plugin
Wordcamp2012 build your pluginWordcamp2012 build your plugin
Wordcamp2012 build your plugin
Alexandre Marreiros
 
Secure All The Things!
Secure All The Things!Secure All The Things!
Secure All The Things!
Dougal Campbell
 
Higher Order WordPress Security
Higher Order WordPress SecurityHigher Order WordPress Security
Higher Order WordPress Security
Dougal Campbell
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do it
Onni Hakala
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
Lester Chan
 
WordPress Plugins
WordPress PluginsWordPress Plugins
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
Yameen Khan
 
Install WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHPInstall WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHP
Rupesh Kumar
 
WordPress for Content Editors
WordPress for Content EditorsWordPress for Content Editors
WordPress for Content Editors
Milan van Bruggen
 
Don't sh** in the Pool
Don't sh** in the PoolDon't sh** in the Pool
Don't sh** in the PoolChris Jean
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
WP Engine
 
Write Your First WordPress Plugin
Write Your First WordPress PluginWrite Your First WordPress Plugin
Write Your First WordPress Plugin
Ibrahim Abdel Fattah Mohamed
 
Ako na vlastne WP temy
Ako na vlastne WP temyAko na vlastne WP temy
Ako na vlastne WP temy
Juraj Kiss
 
Getting Started With Wordpress
Getting Started With WordpressGetting Started With Wordpress
Getting Started With Wordpress
Digital Strategy Works LLC
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
ylefebvre
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
Aggelos Synadakis
 
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
abhim12
 
Coding with jetpack
Coding with jetpackCoding with jetpack
Coding with jetpack
Rich Collier
 
Wordpress plugin creation_overview
Wordpress plugin creation_overviewWordpress plugin creation_overview
Wordpress plugin creation_overview
Daniel Kline
 

What's hot (20)

The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
Wordcamp2012 build your plugin
Wordcamp2012 build your pluginWordcamp2012 build your plugin
Wordcamp2012 build your plugin
 
Secure All The Things!
Secure All The Things!Secure All The Things!
Secure All The Things!
 
Higher Order WordPress Security
Higher Order WordPress SecurityHigher Order WordPress Security
Higher Order WordPress Security
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do it
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
 
Install WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHPInstall WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHP
 
WordPress for Content Editors
WordPress for Content EditorsWordPress for Content Editors
WordPress for Content Editors
 
Don't sh** in the Pool
Don't sh** in the PoolDon't sh** in the Pool
Don't sh** in the Pool
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
Write Your First WordPress Plugin
Write Your First WordPress PluginWrite Your First WordPress Plugin
Write Your First WordPress Plugin
 
Ako na vlastne WP temy
Ako na vlastne WP temyAko na vlastne WP temy
Ako na vlastne WP temy
 
Getting Started With Wordpress
Getting Started With WordpressGetting Started With Wordpress
Getting Started With Wordpress
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
 
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
 
Coding with jetpack
Coding with jetpackCoding with jetpack
Coding with jetpack
 
Wordpress plugin creation_overview
Wordpress plugin creation_overviewWordpress plugin creation_overview
Wordpress plugin creation_overview
 

Similar to WordPress Plugin Development For Beginners

How to Create a Custom WordPress Plugin
How to Create a Custom WordPress PluginHow to Create a Custom WordPress Plugin
How to Create a Custom WordPress Plugin
Andolasoft Inc
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
Steve Mortiboy
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPress
Metronet
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your willTom Jenkins
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
Brad Williams
 
Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
Andy Stratton
 
Introduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin DevelopmentIntroduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin Development
Bruce L Chamoff
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
Aizat Faiz
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Evan Mullins
 
Php Debugger
Php DebuggerPhp Debugger
Php Debugger
guest8cd374
 
Develop FOSS project using Google Code Hosting
Develop FOSS project using Google Code HostingDevelop FOSS project using Google Code Hosting
Develop FOSS project using Google Code Hosting
Narendra Sisodiya
 
How to publish your plugin as open source and contribute to WordPress
How to publish your plugin as open source and contribute to WordPressHow to publish your plugin as open source and contribute to WordPress
How to publish your plugin as open source and contribute to WordPress
Otto Kekäläinen
 
Plugins debugging and developing
Plugins debugging and developingPlugins debugging and developing
Plugins debugging and developingbriancolinger
 
Wordpress security issues
Wordpress security issuesWordpress security issues
Wordpress security issuesDeepu Thomas
 
Extending WordPress - a guide to building your first plugin
Extending WordPress -  a guide to building your first pluginExtending WordPress -  a guide to building your first plugin
Extending WordPress - a guide to building your first plugin
Jonathan Bossenger
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
Paul Withers
 
Securing Word Press Blog
Securing Word Press BlogSecuring Word Press Blog
Securing Word Press Blog
Chetan Gole
 

Similar to WordPress Plugin Development For Beginners (20)

How to Create a Custom WordPress Plugin
How to Create a Custom WordPress PluginHow to Create a Custom WordPress Plugin
How to Create a Custom WordPress Plugin
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPress
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Plug in development
Plug in developmentPlug in development
Plug in development
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Introduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin DevelopmentIntroduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin Development
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Php Debugger
Php DebuggerPhp Debugger
Php Debugger
 
Develop FOSS project using Google Code Hosting
Develop FOSS project using Google Code HostingDevelop FOSS project using Google Code Hosting
Develop FOSS project using Google Code Hosting
 
How to publish your plugin as open source and contribute to WordPress
How to publish your plugin as open source and contribute to WordPressHow to publish your plugin as open source and contribute to WordPress
How to publish your plugin as open source and contribute to WordPress
 
Plugins debugging and developing
Plugins debugging and developingPlugins debugging and developing
Plugins debugging and developing
 
Wordpress security issues
Wordpress security issuesWordpress security issues
Wordpress security issues
 
Extending WordPress - a guide to building your first plugin
Extending WordPress -  a guide to building your first pluginExtending WordPress -  a guide to building your first plugin
Extending WordPress - a guide to building your first plugin
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
 
Securing Word Press Blog
Securing Word Press BlogSecuring Word Press Blog
Securing Word Press Blog
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

WordPress Plugin Development For Beginners

  • 1. WordPress Plugin Development for Beginners John P. Bloch Senior Web Developer Avendi Media, Inc. http://www.johnpbloch.com/ @johnpbloch
  • 2. What Are Plugins?  The stupid answer:  Anything you want*  *theoretically, at least  The useful answer:  Non-essential and elective aspects of any given WordPress installation
  • 3. Wait a Minute... Aren't plugins just extensions of WordPress? Don't they just add functionality that isn't there?
  • 4. Plugins are Part of WordPress  Plugins have primacy of place  Plugins interact with WordPress in the same way WordPress interacts with itself
  • 6. How Do Plugins Work?  Almost all plugin use hooks. There are two kinds of hooks:  Actions  Filters  What's the difference?  Filters expect you to return something, and...  … that's it!  Hooks let you tell WordPress to execute a function when the specified hook fires
  • 7. How To Use Hooks  Filters:  <?php add_filter( 'filter_name', 'function_name' ); ?>  Actions:  <?php add_action( 'action_name', 'func_name' ); ?>  Both functions take two optional arguments:  Priority  Accepted Arguments
  • 8. How To Fire Hooks  To fire an action:  <?php do_action( 'action_name' ); ?>  This fires all functions hooked into that action  To fire a filter:  <?php apply_filters( 'filter_name', 'Filter value' ); ?>  The 'Filter value' will be the first argument of each hooked function  apply_filters will return the filtered input
  • 9. How Does Priority Work? Actions and filters are executed in the order they are added. So this code will echo: First Second Third
  • 10. How Does Priority Work? Priority changes this order. Actions and filters have a default priority of 10. Using a lower number gives it higher priority. This code ouputs: Third First Second
  • 11. Accepted Arguments  Accepted arguments allows you to specify how many arguments to send to a hooked function  Defaults to 1 for both actions and filters  The following would output: Don't mention Joomla Don't mention
  • 12. Some Common Hooks  Actions  init  template_redirect  admin_init  after_setup_theme  wp_loaded  wp_head  wp_footer  admin_menu  Filters  the_content  the_title  wp_title  template_include  body_class  post_class
  • 13. But Wait! There's More!  One more way to hook into WordPress is through shortcodes  Shortcodes are inserted into a post or page from the editor; WordPress replaces the shortcode tags with dynamically generated content  Shortcodes are kind of like HTML:  [foo bar='bar']  [foo bar='bar']Some Content[/foo]
  • 14. How to Add a Shortcode  Shortcodes must be registered:  <?php add_shortcode( 'tag_name', 'function_name' ); ?>  Shortcode handlers take two optional arguments:  Arguments: an array of arguments from the shortcode  Content: the content (if any) of the shortcode  Shortcode handlers should return, not echo, their content
  • 15. An Example of a Shortcode
  • 16. Developer Toolbox  Local development environment  LAMPP Stack (XAMPP – http://apachefriends.org)  Subversion  Windows: TortoiseSVN or Cygwin  Everything else: CLI  Text Editor  FTP client  Mac: Transmit  SSH Client  Windows: Putty  Reference  PHPXref (http://www.phpxref.com)
  • 17. WordPress Developer Toolbox  Official Support Channels  WordPress Codex (http://codex.wordpress.org/)  WordPress Forums (http://wordpress.org/support/)  IRC Channel #wordpress (chat.freenode.net)  Mailing Lists (sort of) (http://codex.wordpress.org/Mailing_Lists)  Unofficial Support Channels  WordPress Answers (http://wordpress.stackexchange.com/)  WordPress Docs (http://wpdocs.labs.thedextrousweb.com/)  Alot of Books
  • 19. Adding Your Plugin to the Directory  http://wordpress.org/extend/plugins/add/  Answer a few questions  Name – Very important! This will determine the name of the directory your plugin creates  Description  Plugin URL (optional)  … And wait!
  • 20. What is SVN? SVN, or Subversion, is a version control program. Others include Git and Mercurial. Subversion is used for core WordPress development/distribution and official plugin development/distribution. Once you have your repository, anybody in the world can check it out. Only you* can check files into it. *Technically, Nacin and some others have global plugin repo commit access. #blamenacin
  • 21. How to Use SVN  If you are on windows and use TortoiseSVN, just follow these next steps substituting ”Click X menu item” for ”Execute X command”  Go to the directory into which you'd like the repo to go:  ~$ cd Documents/svn  Check out your repository for the first time:  ~$ svn co http://plugins.svn.wordpress.org/custom-post-permalinks/ custom-post-permalinks  Edit to your heart's content
  • 22. How to Use SVN  When you're done making changes (or reach a good stopping point), commit your changes:  ~$ svn ci -m 'This is a description of the commit!'  … Tada!
  • 23. Some Other Notes on SVN  Updating your plugin  Tagging vs. Stable Trunk  Branching  Adding committers (and other admin tools)
  • 24. Further Reading  Core.  Core.  Core.  Seriously. Just read core's runtime execution.  Line by line.
  • 25. Now Let's Get Down to Business! Time to switch gears, open VIM, and write a plugin!