SlideShare a Scribd company logo
1 of 75
Beginning WordPress Plugin Development Aizat Faiz aizat.faiz@gmail.com
Download and view at http://blog.aizatto.com/?p=3729
Creative Commons http://www.flickr.com/photos/kwl/4435490471/
By Attribution http://www.flickr.com/photos/balakov/4571468943/
Aizat Faiz http://www.flickr.com/photos/byte/3397174843/ [email_address]
Your Friends / Resources http://www.flickr.com/photos/balakov/4571468943/
WordPress Codex ,[object Object]
WordPress Plugin Directory
Google ,[object Object]
What is a Hook? http://www.flickr.com/photos/kwl/4247555680/
WordPress is the Base http://www.flickr.com/photos/kwl/4247555680/
Plugins are the Blocks http://www.flickr.com/photos/sixteen-miles/3757674953/
Hooks are the Pegs http://www.flickr.com/photos/linuxmatt/92802487/
Actions Filters 2 Kinds of WordPress Hooks
Actions
Actions Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API. ,[object Object],http://codex.wordpress.org/Plugin_API/Action_Reference
Actions Actions = “Do Something”
Filters
Filters Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database); most input and output in WordPress passes through at least one filter. WordPress does some filtering by default, and your plugin can add its own filtering http://codex.wordpress.org/Plugin_API#Filters http://codex.wordpress.org/Plugin_API/Filter_Reference
Filters Filters = Transform
Actions and Filters Actions = “Do Something” Filters = Transform
 
1133
1133 hooks ,[object Object]
Problem: Finding the Right Hook for the Right Job
Hard to Recommend ,[object Object]
WordPress Plugin Directory
Google ,[object Object],[object Object]
http://codex.wordpress.org/Plugin_API/Filter_Reference
 
Writing Your First Plugin
WordPress Directory Structure All Plugins are stored in: /wp-content/plugins/
Plugin Directory Structure ,[object Object]
screenshot-1.png
my-plugin.php ,[object Object]
Uses 'dashes' and not 'underscores' http://codex.wordpress.org/Writing_a_Plugin#Names.2C_Files.2C_and_Locations
readme.txt http://codex.wordpress.org/Writing_a_Plugin#Readme_File http://wordpress.org/extend/plugins/about/readme.txt Useful only for publishing to WordPress Plugin Directory Information about your plugin: Description, Installation, Changelog, Donation Links, Tags, etc...
screenshot-1.png Useful only for publishing to WordPress Plugin Directory
my-plugin.php Your Plugin Code ,[object Object]
Hooks
PHP Code
Template Code
File Structure
Plugin Headers http://codex.wordpress.org/Writing_a_Plugin#Standard_Plugin_Information
Plugin Headers http://codex.wordpress.org/Writing_a_Plugin#Standard_Plugin_Information ,[object Object]
Fill in with your own details
Hooks (Filters)
Hooks (Filters) ,[object Object]
Makes it easier to find
PHP Code
 
Plugin 1 Figure out what you want to do. I want to convert all instances of “WordPress” to “WORDPRESS” in a post's content.
the_content  (filter) http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
add_filter http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
add_filter http://codex.wordpress.org/Plugin_API#Hook_to_WordPress ② ①   Hook Name ②  Callback ①
Hook Callback ,[object Object]
Callback can be either: ,[object Object]
Array of 2 strings (my preference)
Hook Callback ,[object Object]
They do the same thing
I Prefer Array Callbacks ,[object Object]
Lower chances of name conflicts
Easily tell which function belongs to which hook
Filters are Transformations filters have to return a transformation
Filter  return  Values ,[object Object],② ①   return ②  transformation ① http://php.net/manual/en/function.preg-replace.php
 
Plugin 2 Figure out what you want to do. I want to  BOLD all instances of “WORDPRESS” in a post's content.
Hook Priority http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
Priority ② ②  Callback ① ③ ② ② ③   Priority  (optional) ①   Hook Name http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
Which one goes first? WordPress2WORDPRESS#the_content ABolderWordPress#the_content
Default Priority 10 smaller numbers = higher priority larger numbers = lower priority http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
Therefore Order of execution: (10)   WordPress2WORDPRESS#the_content (20)   ABolderWordPress#the_content
 
Plugin 3 Figure out what you want to do. I want to add a class, to represent a post that has more than 10 comments
accepted_args http://codex.wordpress.org/Plugin_API#Hook_to_WordPress

More Related Content

What's hot

Working with Images in WordPress
Working with Images in WordPress Working with Images in WordPress
Working with Images in WordPress
randyhoyt
 
Week 5 - Introduction to plug-ins and widgets
Week 5 - Introduction to plug-ins and widgetsWeek 5 - Introduction to plug-ins and widgets
Week 5 - Introduction to plug-ins and widgets
henri_makembe
 
Week 12 - Search Engine Optimization
Week 12 -  Search Engine OptimizationWeek 12 -  Search Engine Optimization
Week 12 - Search Engine Optimization
henri_makembe
 

What's hot (20)

Your WordPress Site is and is not Hacked - You don't know until you check
Your WordPress Site is and is not Hacked - You don't know until you checkYour WordPress Site is and is not Hacked - You don't know until you check
Your WordPress Site is and is not Hacked - You don't know until you check
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginners
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop API
 
WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
 
Paul Campbell — A Modern Approach to Third-Party Embedded Widgets (Turing Fes...
Paul Campbell — A Modern Approach to Third-Party Embedded Widgets (Turing Fes...Paul Campbell — A Modern Approach to Third-Party Embedded Widgets (Turing Fes...
Paul Campbell — A Modern Approach to Third-Party Embedded Widgets (Turing Fes...
 
Joomla! Plugin Development
Joomla! Plugin DevelopmentJoomla! Plugin Development
Joomla! Plugin Development
 
WordPress Plugins You Cannot Live Without
WordPress Plugins You Cannot Live WithoutWordPress Plugins You Cannot Live Without
WordPress Plugins You Cannot Live Without
 
Fast Loading JavaScript
Fast Loading JavaScriptFast Loading JavaScript
Fast Loading JavaScript
 
Building the Media Block in ReactJS
Building the Media Block in ReactJS Building the Media Block in ReactJS
Building the Media Block in ReactJS
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
wp-cli
wp-cliwp-cli
wp-cli
 
Working with Images in WordPress
Working with Images in WordPress Working with Images in WordPress
Working with Images in WordPress
 
Week 5 - Introduction to plug-ins and widgets
Week 5 - Introduction to plug-ins and widgetsWeek 5 - Introduction to plug-ins and widgets
Week 5 - Introduction to plug-ins and widgets
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Week 12 - Search Engine Optimization
Week 12 -  Search Engine OptimizationWeek 12 -  Search Engine Optimization
Week 12 - Search Engine Optimization
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Introduction to rg\injection
Introduction to rg\injectionIntroduction to rg\injection
Introduction to rg\injection
 
Introduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin DevelopmentIntroduction To Simple WordPress Plugin Development
Introduction To Simple WordPress Plugin Development
 
Writing Your Own WordPress Plugins - WordCamp Kansas City, 2014
Writing Your Own WordPress Plugins - WordCamp Kansas City, 2014Writing Your Own WordPress Plugins - WordCamp Kansas City, 2014
Writing Your Own WordPress Plugins - WordCamp Kansas City, 2014
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 

Viewers also liked

Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
Mainak Goswami
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
Joey Kudish
 
Anatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress ThemeAnatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress Theme
Julie Kuehl
 

Viewers also liked (20)

Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
 
WordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress OptimizationWordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress Optimization
 
Workshop 4: IJssel-Vechtdelta lessons learned
Workshop 4: IJssel-Vechtdelta lessons learnedWorkshop 4: IJssel-Vechtdelta lessons learned
Workshop 4: IJssel-Vechtdelta lessons learned
 
WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post Types
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
 
Custom Post Types and Taxonomies
Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
Custom Post Types and Taxonomies
 
Anatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress ThemeAnatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress Theme
 
Architecture for WordPress on AWS
Architecture for WordPress on AWSArchitecture for WordPress on AWS
Architecture for WordPress on AWS
 
WordPress Code Architecture
WordPress Code ArchitectureWordPress Code Architecture
WordPress Code Architecture
 
numerical analysis
numerical analysisnumerical analysis
numerical analysis
 
Agricultural Economics Mid Term Progress Submission
Agricultural Economics Mid Term Progress SubmissionAgricultural Economics Mid Term Progress Submission
Agricultural Economics Mid Term Progress Submission
 
Water-Food-Energy Nexus in the context of groundwater use in India: Experienc...
Water-Food-Energy Nexus in the context of groundwater use in India: Experienc...Water-Food-Energy Nexus in the context of groundwater use in India: Experienc...
Water-Food-Energy Nexus in the context of groundwater use in India: Experienc...
 
Selecting A Content Management System For Athabasca University
Selecting A Content Management System For Athabasca UniversitySelecting A Content Management System For Athabasca University
Selecting A Content Management System For Athabasca University
 
Proof in Mathematics
Proof in MathematicsProof in Mathematics
Proof in Mathematics
 
[Ronald p. morash] bridge to abstract mathematics
[Ronald p. morash] bridge to abstract mathematics[Ronald p. morash] bridge to abstract mathematics
[Ronald p. morash] bridge to abstract mathematics
 
The Water Energy and Food Security Nexus - is it really new?
The Water Energy and Food Security Nexus - is it really new?The Water Energy and Food Security Nexus - is it really new?
The Water Energy and Food Security Nexus - is it really new?
 
Image processing (Signal Processing)
Image processing (Signal Processing)Image processing (Signal Processing)
Image processing (Signal Processing)
 
MedSpring: the Nexus Water-Energy-Food (W-E-F) to strengthen the EU-Mediterr...
MedSpring:  the Nexus Water-Energy-Food (W-E-F) to strengthen the EU-Mediterr...MedSpring:  the Nexus Water-Energy-Food (W-E-F) to strengthen the EU-Mediterr...
MedSpring: the Nexus Water-Energy-Food (W-E-F) to strengthen the EU-Mediterr...
 
An Agricultural Economics Research Agenda in Ethiopia – Some Reflections
An Agricultural Economics Research Agenda in Ethiopia – Some ReflectionsAn Agricultural Economics Research Agenda in Ethiopia – Some Reflections
An Agricultural Economics Research Agenda in Ethiopia – Some Reflections
 
Irrigation suitability in Malawi
Irrigation suitability in MalawiIrrigation suitability in Malawi
Irrigation suitability in Malawi
 

Similar to Beginning WordPress Plugin Development

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
randyhoyt
 

Similar to Beginning WordPress Plugin Development (20)

Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
 
Amazing WordPress & Productivity Tips
Amazing WordPress & Productivity TipsAmazing WordPress & Productivity Tips
Amazing WordPress & Productivity Tips
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Top 20 word press plugins you've never heard of
Top 20 word press plugins you've never heard ofTop 20 word press plugins you've never heard of
Top 20 word press plugins you've never heard of
 
Top 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard OfTop 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard Of
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
WordPress
WordPressWordPress
WordPress
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
 
Securing Word Press Blog
Securing Word Press BlogSecuring Word Press Blog
Securing Word Press Blog
 
WordPress for Libraries PreConference Workshop
WordPress for Libraries PreConference WorkshopWordPress for Libraries PreConference Workshop
WordPress for Libraries PreConference Workshop
 
What is (not) WordPress
What is (not) WordPressWhat is (not) WordPress
What is (not) WordPress
 
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
 
Write Your First WordPress Plugin
Write Your First WordPress PluginWrite Your First WordPress Plugin
Write Your First WordPress Plugin
 
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
 
WordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteWordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media Institute
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
 

More from Aizat Faiz (7)

Location Aware Browsing
Location Aware BrowsingLocation Aware Browsing
Location Aware Browsing
 
The Age of Collaboration
The Age of CollaborationThe Age of Collaboration
The Age of Collaboration
 
The Future Of Travel
The Future Of TravelThe Future Of Travel
The Future Of Travel
 
Read Write Culture
Read  Write  CultureRead  Write  Culture
Read Write Culture
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Free and Open Source Software Society Malaysia
Free and Open Source Software Society MalaysiaFree and Open Source Software Society Malaysia
Free and Open Source Software Society Malaysia
 
Ruby
RubyRuby
Ruby
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Beginning WordPress Plugin Development

Editor's Notes

  1. The reason we all use WordPress, is because its free.
  2. My slides are also free. Free to use. Free to modify. Free to redistribute.
  3. Head developer at UrekaLabs Create Web applications on Ruby on Rails and PHP Used to do swing dancing, but stopped a year ago, and have massively gained weight
  4. When developing WordPress plugins, there are several friends you need to know
  5. Dirth of information available here Lots of information about everything
  6. Sometimes its not enough The WordPress Codex may not be enough
  7. You are not going to need to know all You are probably only going to use one or two of them
  8. You are not going to need to know all You are probably only going to use one or two of them
  9. There are so many hooks, which one do we need to use? Figure out what you want to do Go through the plugin Action and Filter Reference