SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Último (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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!