SlideShare a Scribd company logo
1 of 11
Building Your First Plugin
A COMPLETE NEWBIE’S GUIDE TO CREATING A PLUGIN
SCOTT DELUZIO
#wcphx
@scottdeluzio
About me: Scott DeLuzio
• 14 Plugins on WordPress.org
• Core contributor
• Originally not a developer – you can do it too!
• Paid plugins include
• WP-CRM System
• WP1099
• Conditional Checkout Fields
• WP In-Post Ads
#wcphx
@scottdeluzio
What is a plugin?
• Software that adds to or changes how WordPress works
• Written in PHP – other code can be used too
• Easy to add features
• Myth: plugins slow your site down
#wcphx
@scottdeluzio
Theme vs. Plugin
THEME
• Think exterior of a car
• Controls look of site
• Placement of content
• Header, Footer, Sidebar,
Content
PLUGIN
• Think interior features of a car
• Controls functionality of site
• Creates content types
• Adds features
#wcphx
@scottdeluzio
Why your site might need plugins
• WordPress without plugins is limited
• Power of WordPress is in extendibility
• SEO
• eCommerce
• Connect to 3rd party services
• …about 54,000 others
• Or your own plugin
#wcphx
@scottdeluzio
Danger of functions.php
• Tutorials say paste into theme’s functions.php file
• Easier than explaining how to make a plugin
• Theme updates remove changes
• Use a child theme!
• Can’t switch themes without losing custom code
#wcphx
@scottdeluzio
Benefits of custom plugins
• Won’t be lost with theme update (functions.php)
• Free to change themes
• Easier to troubleshoot issues
• One specific function per plugin
#wcphx
@scottdeluzio
What you need for a custom plugin
• Text editor
• Not Microsoft Word (or other word processors)
• Notepad (Windows) / TextEdit (Mac)
• Notepad++ – Windows (free/Open Source)
• Atom – OSX, Windows, Linux (free/Open Source)
• Other paid / not open source options available
• FTP/Git/Backup
• Avoid the plugin/theme editor in WordPress
• Use a development site!
#wcphx
@scottdeluzio
Best practices
• define( ‘WP_DEBUG’, true );
• Use WordPress coding standards
• https://codex.wordpress.org/
• https://developer.wordpress.org/
• Use prefixes
#wcphx
@scottdeluzio
What will the plugin do?
• Create custom post types
• https://developer.wordpress.org/plugins/post-types/
• Create a shortcode
• https://developer.wordpress.org/plugins/shortcodes/
#wcphx
@scottdeluzio
Let’s Code Our Own Plugin
https://github.com/ScottDeLuzio/wcphx2018
#wcphx
@scottdeluzio

More Related Content

What's hot

Content as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSContent as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSPantheon
 
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie DilsThe Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie DilsWP Engine
 
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...Advancing Content Management for Omni-Channel User Experiences by Roland Bene...
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...eZ Systems
 
The Ultimate WordPress Development Environment
The Ultimate WordPress Development EnvironmentThe Ultimate WordPress Development Environment
The Ultimate WordPress Development EnvironmentMatt Geri
 
Build a DNN Module in Minutes
Build a DNN Module in MinutesBuild a DNN Module in Minutes
Build a DNN Module in MinutesWill Strohl
 
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Viktor Vogel
 
DNN Database Tips & Tricks
DNN Database Tips & TricksDNN Database Tips & Tricks
DNN Database Tips & TricksWill Strohl
 
Blazor - .NET in the Browser!
Blazor - .NET in the Browser!Blazor - .NET in the Browser!
Blazor - .NET in the Browser!David Paquette
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesRobert MacLean
 
Cross CMS plugin development using AWF
Cross CMS plugin development using AWFCross CMS plugin development using AWF
Cross CMS plugin development using AWFTim Plummer
 
To infinity and Beyond with Plone 5!
To infinity and Beyond with Plone 5!To infinity and Beyond with Plone 5!
To infinity and Beyond with Plone 5!Rikupekka Oksanen
 
Website using word press
Website using word pressWebsite using word press
Website using word pressVishalPatir
 
Wordcamp 2010 presentation
Wordcamp 2010 presentationWordcamp 2010 presentation
Wordcamp 2010 presentationJonny Allbut
 
Rapid application development for WordPress using AWF
Rapid application development for WordPress using AWFRapid application development for WordPress using AWF
Rapid application development for WordPress using AWFTim Plummer
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsJoe Querin
 
2011 05 word-press-not-just-for-blogging-anymore
2011 05 word-press-not-just-for-blogging-anymore2011 05 word-press-not-just-for-blogging-anymore
2011 05 word-press-not-just-for-blogging-anymoreRudy Duke
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesAndy_Gaskell
 
Wordpress Questions & Answers
Wordpress Questions & AnswersWordpress Questions & Answers
Wordpress Questions & AnswersNicole Dion
 
Website Using WordPress
Website Using WordPressWebsite Using WordPress
Website Using WordPressVishalPatir
 
What is the Responsibility of Plugin Developers?
What is the Responsibility of Plugin Developers?What is the Responsibility of Plugin Developers?
What is the Responsibility of Plugin Developers?Takayuki Miyoshi
 

What's hot (20)

Content as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSContent as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMS
 
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie DilsThe Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
 
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...Advancing Content Management for Omni-Channel User Experiences by Roland Bene...
Advancing Content Management for Omni-Channel User Experiences by Roland Bene...
 
The Ultimate WordPress Development Environment
The Ultimate WordPress Development EnvironmentThe Ultimate WordPress Development Environment
The Ultimate WordPress Development Environment
 
Build a DNN Module in Minutes
Build a DNN Module in MinutesBuild a DNN Module in Minutes
Build a DNN Module in Minutes
 
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
 
DNN Database Tips & Tricks
DNN Database Tips & TricksDNN Database Tips & Tricks
DNN Database Tips & Tricks
 
Blazor - .NET in the Browser!
Blazor - .NET in the Browser!Blazor - .NET in the Browser!
Blazor - .NET in the Browser!
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutes
 
Cross CMS plugin development using AWF
Cross CMS plugin development using AWFCross CMS plugin development using AWF
Cross CMS plugin development using AWF
 
To infinity and Beyond with Plone 5!
To infinity and Beyond with Plone 5!To infinity and Beyond with Plone 5!
To infinity and Beyond with Plone 5!
 
Website using word press
Website using word pressWebsite using word press
Website using word press
 
Wordcamp 2010 presentation
Wordcamp 2010 presentationWordcamp 2010 presentation
Wordcamp 2010 presentation
 
Rapid application development for WordPress using AWF
Rapid application development for WordPress using AWFRapid application development for WordPress using AWF
Rapid application development for WordPress using AWF
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
2011 05 word-press-not-just-for-blogging-anymore
2011 05 word-press-not-just-for-blogging-anymore2011 05 word-press-not-just-for-blogging-anymore
2011 05 word-press-not-just-for-blogging-anymore
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiences
 
Wordpress Questions & Answers
Wordpress Questions & AnswersWordpress Questions & Answers
Wordpress Questions & Answers
 
Website Using WordPress
Website Using WordPressWebsite Using WordPress
Website Using WordPress
 
What is the Responsibility of Plugin Developers?
What is the Responsibility of Plugin Developers?What is the Responsibility of Plugin Developers?
What is the Responsibility of Plugin Developers?
 

Similar to Building your first plugin

Creating a Documentation Portal
Creating a Documentation PortalCreating a Documentation Portal
Creating a Documentation PortalSteve Anderson
 
Wordpress intro
Wordpress introWordpress intro
Wordpress introthe-colab
 
Rapid development of help files and user documentation in Dr.Explain 5
Rapid development of help files and user documentation in Dr.Explain 5Rapid development of help files and user documentation in Dr.Explain 5
Rapid development of help files and user documentation in Dr.Explain 5Dennis Zhuravlev (a.k.a. Crane)
 
WordPress & Other Content Management Systems
WordPress & Other Content Management SystemsWordPress & Other Content Management Systems
WordPress & Other Content Management SystemsEmily Lewis
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesJer Clarke
 
Introduction to TomatoCMS
Introduction to TomatoCMSIntroduction to TomatoCMS
Introduction to TomatoCMSPhuoc Nguyen
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Developing Custom WordPress Themes for Clients
Developing Custom WordPress Themes for ClientsDeveloping Custom WordPress Themes for Clients
Developing Custom WordPress Themes for ClientsSteven Slack
 
The WordPress University
The WordPress UniversityThe WordPress University
The WordPress UniversityStephanie Leary
 
Alice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu
 
Release Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnPRelease Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnPPetter Skodvin-Hvammen
 
Writing Your First Plugin
Writing Your First PluginWriting Your First Plugin
Writing Your First PluginGeorge Ornbo
 
WordPress - fixing sites with problems
WordPress - fixing sites with problemsWordPress - fixing sites with problems
WordPress - fixing sites with problemsVictoria Pickering
 
Why & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginWhy & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginJoe Querin
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With LoveUp2 Technology
 
Introduce the WordPress
Introduce the WordPressIntroduce the WordPress
Introduce the WordPressHoan Tran
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 

Similar to Building your first plugin (20)

Creating a Documentation Portal
Creating a Documentation PortalCreating a Documentation Portal
Creating a Documentation Portal
 
Wordpress intro
Wordpress introWordpress intro
Wordpress intro
 
WordPress plugins
WordPress pluginsWordPress plugins
WordPress plugins
 
Rapid development of help files and user documentation in Dr.Explain 5
Rapid development of help files and user documentation in Dr.Explain 5Rapid development of help files and user documentation in Dr.Explain 5
Rapid development of help files and user documentation in Dr.Explain 5
 
WordPress & Other Content Management Systems
WordPress & Other Content Management SystemsWordPress & Other Content Management Systems
WordPress & Other Content Management Systems
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
 
Introduction to TomatoCMS
Introduction to TomatoCMSIntroduction to TomatoCMS
Introduction to TomatoCMS
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Developing Custom WordPress Themes for Clients
Developing Custom WordPress Themes for ClientsDeveloping Custom WordPress Themes for Clients
Developing Custom WordPress Themes for Clients
 
The WordPress University
The WordPress UniversityThe WordPress University
The WordPress University
 
Alice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu - WordPress For Beginners
Alice Phieu - WordPress For Beginners
 
Release Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnPRelease Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnP
 
Writing Your First Plugin
Writing Your First PluginWriting Your First Plugin
Writing Your First Plugin
 
Pimp your wp site
Pimp your wp sitePimp your wp site
Pimp your wp site
 
WordPress - fixing sites with problems
WordPress - fixing sites with problemsWordPress - fixing sites with problems
WordPress - fixing sites with problems
 
Why & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginWhy & How to Create a WordPress Plugin
Why & How to Create a WordPress Plugin
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With Love
 
Introduce the WordPress
Introduce the WordPressIntroduce the WordPress
Introduce the WordPress
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 

Recently uploaded

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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Recently uploaded (20)

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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
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!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

Building your first plugin

  • 1. Building Your First Plugin A COMPLETE NEWBIE’S GUIDE TO CREATING A PLUGIN SCOTT DELUZIO #wcphx @scottdeluzio
  • 2. About me: Scott DeLuzio • 14 Plugins on WordPress.org • Core contributor • Originally not a developer – you can do it too! • Paid plugins include • WP-CRM System • WP1099 • Conditional Checkout Fields • WP In-Post Ads #wcphx @scottdeluzio
  • 3. What is a plugin? • Software that adds to or changes how WordPress works • Written in PHP – other code can be used too • Easy to add features • Myth: plugins slow your site down #wcphx @scottdeluzio
  • 4. Theme vs. Plugin THEME • Think exterior of a car • Controls look of site • Placement of content • Header, Footer, Sidebar, Content PLUGIN • Think interior features of a car • Controls functionality of site • Creates content types • Adds features #wcphx @scottdeluzio
  • 5. Why your site might need plugins • WordPress without plugins is limited • Power of WordPress is in extendibility • SEO • eCommerce • Connect to 3rd party services • …about 54,000 others • Or your own plugin #wcphx @scottdeluzio
  • 6. Danger of functions.php • Tutorials say paste into theme’s functions.php file • Easier than explaining how to make a plugin • Theme updates remove changes • Use a child theme! • Can’t switch themes without losing custom code #wcphx @scottdeluzio
  • 7. Benefits of custom plugins • Won’t be lost with theme update (functions.php) • Free to change themes • Easier to troubleshoot issues • One specific function per plugin #wcphx @scottdeluzio
  • 8. What you need for a custom plugin • Text editor • Not Microsoft Word (or other word processors) • Notepad (Windows) / TextEdit (Mac) • Notepad++ – Windows (free/Open Source) • Atom – OSX, Windows, Linux (free/Open Source) • Other paid / not open source options available • FTP/Git/Backup • Avoid the plugin/theme editor in WordPress • Use a development site! #wcphx @scottdeluzio
  • 9. Best practices • define( ‘WP_DEBUG’, true ); • Use WordPress coding standards • https://codex.wordpress.org/ • https://developer.wordpress.org/ • Use prefixes #wcphx @scottdeluzio
  • 10. What will the plugin do? • Create custom post types • https://developer.wordpress.org/plugins/post-types/ • Create a shortcode • https://developer.wordpress.org/plugins/shortcodes/ #wcphx @scottdeluzio
  • 11. Let’s Code Our Own Plugin https://github.com/ScottDeLuzio/wcphx2018 #wcphx @scottdeluzio

Editor's Notes

  1. Before beginning, this is a beginner level talk. If anyone has developed plugins, or is an advanced developer this might be nap time. If you’re one of those people and are here for moral support, thank you. You’re more than welcome to stay but I won’t be offended if you duck out.
  2. I have 14 plugins on WordPress.org I contributed to WordPress core, so if your site is updated to 4.9 or higher, some of my code is already on your site My background is not in software development. Have a degree in accounting Was a soldier Taught myself how to code You can do it too!
  3. Plugins are simply software that changes how WordPress works They are written in PHP code, but other code like JavaScript can be used too Plugins make it easy to add features to your site. Out of the box WordPress doesn’t have certain features but you can add them with plugins. Contact forms Page builders eCommerce SEO Myth: plugins slow down your site Plugins aren’t inherently bad or slow Some hosts have perpetuated this myth by saying “you have too many plugins” That’s a lazy way of saying “there are a lot of plugins on your site, and one of them might be slowing your site down but I don’t care to look at each one individually” The hope is you get rid of some plugins, the problem magically fixes itself, and you never call back for help Some plugins actually speed up your site (caching, optimize images, etc.) Truth: badly coded plugins can slow down your site.
  4. I want to make sure we understand the difference between themes and plugins Themes Imagine the exterior of a car. The color, shape, type of car (convertible, SUV, minivan) Themes control the look of the site Controls where content is placed Manages the appearance of the site’s header, footer, sidebar, and content areas Plugins Think about the interior features of a car. The engine, GPS, heated seats, etc. Plugins control the functionality of your site. While themes control the placement of content, plugins can create new types of content Think products in an eCommerce store Plugins can add features to your site that don’t come with WordPress
  5. A plain install of WordPress is pretty limited. Don’t get me wrong, it is 100% all you need for a simple website. Can make a basic business brochure site Start a blog No plugins are needed at all for this Power of WordPress is in it’s extendibility Simple to add plugins for: SEO eCommerce Contact Forms Connecting to 3rd party services And about 54,000 other things
  6. Online tutorials provide you with code snippets that you can copy and paste onto your site. Many suggest copying into your theme’s functions.php file I think this is a lazy “one size fits all” approach Sometimes functions.php is the appropriate place for this code, but not always The way tutorials are written, copying and pasting in their entirety may break your site. Nothing may be wrong with the code – operator error https://pippinsplugins.com/quick-introduction-to-action-hooks/ Theme Updates If you aren’t using a child theme, and your theme gets an update your custom code will be lost Child themes will fix this issue. A child theme is a theme that inherits a parent theme’s features, but uses it’s own code to modify or override the parent theme a bit But if you put your code in a child theme’s functions.php you can’t switch themes without losing the custom code. This might be OK if the code is doing something specific to the theme Ex: Make sidebar or footer appear differently on certain pages. Or changing the size of your thumbnail images. Not if there is functionality that you want to keep regardless of how your site looks.
  7. Custom plugins will live forever on your site regardless of theme updates, or if you’ve changed your theme. It’s also easier to troubleshoot issues in a custom plugin. Each plugin should do one thing. That way if you’re having trouble with that thing, you know exactly where to look to fix it. Ex: Shortcode adds content to your page. If the page acts funny or has errors when the shortcode is in it, you know the shortcode plugin is messed up. Fix it or disable it. Some popular contact form plugins create a form that you can use on your site. They also have add-on plugins that let you connect to third party services, or do other things. Imagine if all of the add-ons were baked into the main plugin, and the contact form stopped working correctly. Which add-on’s code caused it to stop? With the code separated into multiple plugins, it’s easy to disable a plugin to isolate the issue.
  8. Text Editor Microsoft Word can technically write text, but can’t save as PHP. Reasons are technical, and not important – just don’t use it. Built in text editors on Windows or Mac computers will work, but not really built for this purpose. Free open source options available that can help catch errors in code, auto format code, and other benefits. Code highlighting helps identify errors. Paid non-open source options are also available. I use Sublime Text, but I won’t get into that here. FTP/Git For PHP Code PHP code can come from tutorials – only take from trusted sources Write your own code if you’re familiar with PHP When you do so, avoid using the plugin or theme editor in WordPress. If you make a mistake, it can bring the whole site down, and you won’t have a way to revert changes. Use FTP to upload changes to your server. That way if there’s a problem, you can CTRL+Z to undo changes on your computer and re-upload a working version. Get a Development Site Prevents your live site from crashing when something goes wrong. If editing CSS, the worst case is you’ll make the site look ugly. If editing PHP, and you’re missing one comma, quote, or semi-colon, you can bring the whole site down. Many hosts offer staging, or development environments. Use that if you have nothing else to use. Or buy a cheap hosting account to build on. Can also install a server locally on your computer. Makes it easy to spin up sites quickly and test.
  9. define( ‘WP_DEBUG’, true ); Put this in your wp-config.php file in the site’s root directory. This will output errors onto the screen, and help identify issues. Don’t use on a live site. Coding standards Prefix functions If your plugin has a generic function name that is used somewhere else, it will conflict with the other function. Example: your plugin adds a shortcode, and you use “add_shortcode” as a function name. Well WordPress already uses that, and you’ll cause an error. Call it “my_plugin_name_add_shortcode” instead.
  10. What are custom post types? WP comes with 5 default post types post, page, attachment, revision, menu Custom post types handle specific content types eCommerce site might have a Products CPT Education site might have Assignments CPT Movie review site might have Movies and Actors as separate CPTs Think about it this way, posts is a default post type. That’s where blog posts show up. Not all content is a blog post, and shouldn’t show up in your blog’s feed. You wouldn’t want a new blog post to show up every time you uploaded an image, right? Images are your “attachment” post type. Just like you wouldn’t want every product to show up on your blog feed on an eCommerce site. What are shortcodes? Shortcodes provide a way to dynamically interact with your site’s content. You can’t put PHP code into a post or page for security reasons. You can put in a shortcode to do all sorts of things. Shortcodes run a PHP function, which can display data from your site, or even another site through an API.
  11. Every plugin should have: A folder – technically this isn’t needed, but it is useful for organizing if the plugin will have more than one file. A PHP file with a header comment Header comment must at a minimum contain the plugin name. Name should be unique. Another plugin on your site with same name will be confusing – probably can’t save that way anyways, or one will override the other. Another plugin on WordPress.org with same name will cause your plugin to be deleted when the other plugin gets updated. Header comment can optionally also contain: Plugin URL: The homepage of the plugin – can’t use WordPress.org URL Description: A short description, which is shown on the Plugins page in WP Admin. Keep under 140 characters. Version: 1.0, 1.1, etc. This helps keep track of changes, and lets people know there is a new version available. Author: The name of the author, or a comma separated list of author names if more than one Author URL: The author’s website License: The name of the license that the plugin is distributed under (e.g. GPL2) License URL: A link to the license text Text Domain: A common string that denotes all text belonging to your plugin. This makes it easier to translate your plugin later on. If you’re building it for yourself and not distributing it, this isn’t necessary. Domain Path: The location of your language translation files.