SlideShare a Scribd company logo
1 of 25
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 PresentationDougal Campbell
 
Higher Order WordPress Security
Higher Order WordPress SecurityHigher Order WordPress Security
Higher Order WordPress SecurityDougal 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 itOnni Hakala
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPressLester Chan
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsYameen Khan
 
Install WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHPInstall WordPress Blogging Software with EasyPHP
Install WordPress Blogging Software with EasyPHPRupesh Kumar
 
WordPress for Content Editors
WordPress for Content EditorsWordPress for Content Editors
WordPress for Content EditorsMilan 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-CLIWP Engine
 
Ako na vlastne WP temy
Ako na vlastne WP temyAko na vlastne WP temy
Ako na vlastne WP temyJuraj Kiss
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
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 jetpackRich Collier
 
Wordpress plugin creation_overview
Wordpress plugin creation_overviewWordpress plugin creation_overview
Wordpress plugin creation_overviewDaniel 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 PluginAndolasoft 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 developmentSteve Mortiboy
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressMetronet
 
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 PluginBrad 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 DevelopmentBrad Williams
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
Introduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin DevelopmentIntroduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin DevelopmentBruce L Chamoff
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentAizat 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 DevelopmentEvan Mullins
 
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 HostingNarendra 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 WordPressOtto 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 pluginJonathan 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 BlogChetan 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

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
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - 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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
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
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

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
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - 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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
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!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
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
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

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!