SlideShare a Scribd company logo
1 of 17
LET’S WRITE A PLUGIN
STUPID WORDPRESS TRICKS PART 0.1A
BRIAN LAYMAN
HTTP://EHERMITSINC.COM
HTTP://SLIDESHARE.NET/BRIANLAYMAN
• Brian Layman
• I work from home
• I spend all day on the computer
• All best my friends are online
• I don’t hang out at parties
• I spend my day in a cave like room
• Yes, I am an eHermit
http://eHermitsInc.com
INTRODUCTION
MY WORLD
http://imgs.xkcd.com/comics/tech_support_cheat_sheet.png
Our
Dark
Secret
BEFORE WE START TO PLAY
• What is a plugin?
• What can plugins do?
• What do you need to know?
• “But I heard plugins make your site slow!”
• “But I heard that plugins make your site insecure!”
PLUGIN SURVIVAL KIT
• http://wordpress.org/plugins/ - Look for a plugin that is similar
• http://wordpress.org/plugins/about/ - Describes how to create a plugin
• http://codex.wordpress.org/ - Your guide
• http://codex.wordpress.org/Writing_a_Plugin
• http://codex.wordpress.org/Plugin_API/Action_Reference - When actions are called
• http://codex.wordpress.org/Plugin_API/Filter_Reference - List of common Filters
• http://themergency.com/generators/wordpress-plugin-boilerplate/ - Basics
• http://generatewp.com/ - Helps add Features
PLUGIN
• A Plugin is a group of php functions that can extend the functionality present in a standard
WordPress weblog. These functions may all be defined in one php file, or may be spread
among more than one file. Usually, a plugin is a php file that can be uploaded to the "wp-
content/plugins" directory on your webserver, where you have installed WordPress. Once you
have uploaded the plugin file, you should be able to "turn it on" or Enable it from the "Plugins"
page in the administration interface of your weblog. The WordPress source code contains
hooks that can be used by plugins.
• See also: Hack, Hacking
• Related articles: Plugins
http://codex.wordpress.org/Glossary
HOOK
• Hooks are specified, by the developer, in Actions and Filters. Here is a (hopefully) complete
list of all existing Hooks within WordPress.
Because Hooks are required by Actions and Filter you may hear the phrase "Action Hooks" and
"Filter Hooks" used from time to time.
In technical and strict terms: a Hook is an event, i.e. event as understood by Observer pattern,
invoked by the do_action() orapply_filters() call that afterwards triggers all
the action or filter functions, previously hooked to that event usingadd_action() or add_filter(),
respectively.
•See also: Action, Filter
•Related articles: Hooks, Actions and Filters, Plugin API/Hooks
http://codex.wordpress.org/Glossary
FILTER
In WordPress, a Filter is a function that is associated with an existing Action by
specifying any existing Hook.
Developers can create custom Filters using the Filter API to replace code from
an existing Action. This process is called "hooking".
Custom Filters differ from custom Actions because custom Actions allow you
to add or remove code from existing Actions. Whereas custom Filters allow you
to replace specific data (such as a variable) found within an existing Action.
•See also: Action, Hook, Terminology Confusion
•Related articles: Filters, Filter Reference, add_filter()
http://codex.wordpress.org/Glossary
ACTION
• In WordPress; an Action is a PHP function that is executed at specific points throughout the
WordPress Core.
Developers can create a custom Action using the Action API to add or remove code from an
existing Action by specifying any existing Hook. This process is called "hooking".
For example: A developer may want to add code to the footer of a Theme. This could be
accomplished by writing new function, then Hooking it to the wp_footer Action.
Custom Actions differ from custom Filters because custom Actions allow you to add or
remove code from existing Actions. Whereas custom Filters allow you to replace specific data
(such as a variable) found within an existing Action.
•See also: Filter, Hook, Terminology Confusion
•Related articles: Actions, Action Reference, add_action()
•Forum posts: Filters vs. Actions Discussion and Explanation
http://codex.wordpress.org/Glossary
OK – HOW ARE WE DOING?
HELLO DOLLY
LET’S PLAY
• We’re going to use the tools we have seen to create a plugin
• Let’s mess with Dolly’s head a little bit
• Using actions
• Using filters
• Including CSS
• Including Scripts
BRIAN DID MIRACULOUS STUFF YOU CAN’T SEE IN
THE DOWNLOADED SLIDESHOW
• Bet you wish you were at Ohio’s 2014 North Canton WordCamp
• Then you could have seen us do all the fun stuff we did
• We’re sorry you missed it
• Maybe you can make it next year..
• OK next slide…
FIGURING OUT WHERE YOU MESSED UP
• http://codex.wordpress.org/Editing_wp-config.php
@ini_set( 'log_errors', On' );
@ini_set( 'error_log', '/home/example/php_error.log' );
@ini_set( 'display_errors', 'On' );
@ini_set( 'error_reporting', E_ALL );
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', false );
define( 'WP_DEBUG_DISPLAY', true );
DOING THINGS RIGHT
• Data Validation
• https://codex.wordpress.org/Data_Validation
• esc_attr, wp kses, esc_url
• Use $wpdb for database access
• get_var, get_row, insert, update, delete
• Use prepare for custom queries
• $wpdb->query( $wpdb->prepare(“select blah from foo where i= %d”, $myintvar )
BRIAN LAYMAN
http://eHermitsinc.com
http://thecodecave.com
http://www.slideshare.net/brianlayman
http://twitter.com/brianlayman
@eHermits
My info->your phone, Txt “ehermit” to 50500
Brian@eHermitsInc.com

More Related Content

What's hot

WordPress Security Basics - Melbourne WordPress User Meetup
WordPress Security Basics - Melbourne WordPress User MeetupWordPress Security Basics - Melbourne WordPress User Meetup
WordPress Security Basics - Melbourne WordPress User MeetupChris Burgess
 
Emergency WordPress Troubleshooting
Emergency WordPress TroubleshootingEmergency WordPress Troubleshooting
Emergency WordPress TroubleshootingTiffany Bridge
 
WordPress Security
WordPress SecurityWordPress Security
WordPress SecurityNathan Platt
 
How to create a WordPress Site
How to create a WordPress Site How to create a WordPress Site
How to create a WordPress Site MuhammadUsaid2
 
WordPress Security Essentials
WordPress Security EssentialsWordPress Security Essentials
WordPress Security EssentialsAngela Bowman
 
WordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityWordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityThe Toolbox, Inc.
 
WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014The Toolbox, Inc.
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate WorkshopThe Toolbox, Inc.
 
WordPress Security
WordPress SecurityWordPress Security
WordPress SecurityIvan Storck
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityMichelle Davies (Hryvnak)
 
8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress websiteSiteGround.com
 
Coding with jetpack
Coding with jetpackCoding with jetpack
Coding with jetpackRich Collier
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and SecurityJoe Casabona
 
WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013Thor Kristiansen
 
Building Secure WordPress Sites
Building Secure WordPress Sites Building Secure WordPress Sites
Building Secure WordPress Sites Catch Themes
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best PracticesRobert Vidal
 
Introduction to Wordpress (Research Based)
Introduction to Wordpress (Research Based)Introduction to Wordpress (Research Based)
Introduction to Wordpress (Research Based)Anjum Hashir
 

What's hot (20)

WordPress Security Basics - Melbourne WordPress User Meetup
WordPress Security Basics - Melbourne WordPress User MeetupWordPress Security Basics - Melbourne WordPress User Meetup
WordPress Security Basics - Melbourne WordPress User Meetup
 
Emergency WordPress Troubleshooting
Emergency WordPress TroubleshootingEmergency WordPress Troubleshooting
Emergency WordPress Troubleshooting
 
WordPress Security
WordPress SecurityWordPress Security
WordPress Security
 
How to create a WordPress Site
How to create a WordPress Site How to create a WordPress Site
How to create a WordPress Site
 
WordPress Security Essentials
WordPress Security EssentialsWordPress Security Essentials
WordPress Security Essentials
 
WordPress Fav Plugins & Security
WordPress Fav Plugins & SecurityWordPress Fav Plugins & Security
WordPress Fav Plugins & Security
 
WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014WordCamp Boston WordPress plugins-8-2014
WordCamp Boston WordPress plugins-8-2014
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate Workshop
 
WordPress Security
WordPress SecurityWordPress Security
WordPress Security
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
 
Wordpress introduction
Wordpress introductionWordpress introduction
Wordpress introduction
 
8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website
 
Coding with jetpack
Coding with jetpackCoding with jetpack
Coding with jetpack
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
 
Installing and Setting Up WordPress
Installing and Setting Up WordPressInstalling and Setting Up WordPress
Installing and Setting Up WordPress
 
WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013
 
Using Wordpress for Internet Publishing--TechConnections version
Using Wordpress for Internet Publishing--TechConnections versionUsing Wordpress for Internet Publishing--TechConnections version
Using Wordpress for Internet Publishing--TechConnections version
 
Building Secure WordPress Sites
Building Secure WordPress Sites Building Secure WordPress Sites
Building Secure WordPress Sites
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
 
Introduction to Wordpress (Research Based)
Introduction to Wordpress (Research Based)Introduction to Wordpress (Research Based)
Introduction to Wordpress (Research Based)
 

Similar to Let’s write a plugin

2016 WordCamp Pittsburgh - Let's Write a Plugin
2016 WordCamp Pittsburgh - Let's Write a Plugin2016 WordCamp Pittsburgh - Let's Write a Plugin
2016 WordCamp Pittsburgh - Let's Write a PluginBrian Layman
 
WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)MuhammadKashif596
 
Intro to WordPress Plugins
Intro to WordPress PluginsIntro to WordPress Plugins
Intro to WordPress Pluginszamoose
 
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress pluginJohn Tighe
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With LoveUp2 Technology
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Ian Wilson
 
Decoding Core Contribution - WordCamp San Diego 2013
Decoding Core Contribution - WordCamp San Diego 2013Decoding Core Contribution - WordCamp San Diego 2013
Decoding Core Contribution - WordCamp San Diego 2013GetSource
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsRich Bradshaw
 
Getting Started with WordPress Plugin Development
Getting Started with WordPress Plugin DevelopmentGetting Started with WordPress Plugin Development
Getting Started with WordPress Plugin DevelopmentAbhishek Deshpande
 
Introduction to Wordpress Hooks
Introduction to Wordpress HooksIntroduction to Wordpress Hooks
Introduction to Wordpress HooksAnthony Hartnell
 
The Web Application Hackers Toolchain
The Web Application Hackers ToolchainThe Web Application Hackers Toolchain
The Web Application Hackers Toolchainjasonhaddix
 
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)Thinkful
 
Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Michele Butcher-Jones
 
JavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxJavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxGennady Feldman
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!David Wolfpaw
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your willTom Jenkins
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaGeorge Wilson
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin developmentLuc De Brouwer
 

Similar to Let’s write a plugin (20)

2016 WordCamp Pittsburgh - Let's Write a Plugin
2016 WordCamp Pittsburgh - Let's Write a Plugin2016 WordCamp Pittsburgh - Let's Write a Plugin
2016 WordCamp Pittsburgh - Let's Write a Plugin
 
WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)WordPress Hooks (Actions & Filters)
WordPress Hooks (Actions & Filters)
 
Intro to WordPress Plugins
Intro to WordPress PluginsIntro to WordPress Plugins
Intro to WordPress Plugins
 
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress plugin
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With Love
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
Decoding Core Contribution - WordCamp San Diego 2013
Decoding Core Contribution - WordCamp San Diego 2013Decoding Core Contribution - WordCamp San Diego 2013
Decoding Core Contribution - WordCamp San Diego 2013
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Getting Started with WordPress Plugin Development
Getting Started with WordPress Plugin DevelopmentGetting Started with WordPress Plugin Development
Getting Started with WordPress Plugin Development
 
Introduction to Wordpress Hooks
Introduction to Wordpress HooksIntroduction to Wordpress Hooks
Introduction to Wordpress Hooks
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
The Web Application Hackers Toolchain
The Web Application Hackers ToolchainThe Web Application Hackers Toolchain
The Web Application Hackers Toolchain
 
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
 
Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?
 
Hacking 101
Hacking 101Hacking 101
Hacking 101
 
JavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefoxJavaScript debugging diagnostic web tools and firefox
JavaScript debugging diagnostic web tools and firefox
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and Joomla
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin development
 

More from Brian Layman

WordPress Rest API
WordPress Rest APIWordPress Rest API
WordPress Rest APIBrian Layman
 
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...Brian Layman
 
Word Camp North Canton 2013 - Say what? Say that again in plain English...
Word Camp North Canton 2013 - Say what? Say that again in plain English...Word Camp North Canton 2013 - Say what? Say that again in plain English...
Word Camp North Canton 2013 - Say what? Say that again in plain English...Brian Layman
 
WordPress 3.8 Beta 1
WordPress 3.8 Beta 1WordPress 3.8 Beta 1
WordPress 3.8 Beta 1Brian Layman
 
Brethren - What Does It Mean?
Brethren - What Does It Mean?Brethren - What Does It Mean?
Brethren - What Does It Mean?Brian Layman
 

More from Brian Layman (8)

WordPress Rest API
WordPress Rest APIWordPress Rest API
WordPress Rest API
 
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...
Drupal & Joomla & WordPress.. Oh My! A quick round-up of the three most popul...
 
Unfailing Love
Unfailing LoveUnfailing Love
Unfailing Love
 
Word Camp North Canton 2013 - Say what? Say that again in plain English...
Word Camp North Canton 2013 - Say what? Say that again in plain English...Word Camp North Canton 2013 - Say what? Say that again in plain English...
Word Camp North Canton 2013 - Say what? Say that again in plain English...
 
WordPress 3.5
WordPress 3.5WordPress 3.5
WordPress 3.5
 
Why WordPress?
Why WordPress?Why WordPress?
Why WordPress?
 
WordPress 3.8 Beta 1
WordPress 3.8 Beta 1WordPress 3.8 Beta 1
WordPress 3.8 Beta 1
 
Brethren - What Does It Mean?
Brethren - What Does It Mean?Brethren - What Does It Mean?
Brethren - What Does It Mean?
 

Recently uploaded

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
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
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Recently uploaded (20)

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
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
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

Let’s write a plugin

  • 1. LET’S WRITE A PLUGIN STUPID WORDPRESS TRICKS PART 0.1A BRIAN LAYMAN HTTP://EHERMITSINC.COM HTTP://SLIDESHARE.NET/BRIANLAYMAN
  • 2. • Brian Layman • I work from home • I spend all day on the computer • All best my friends are online • I don’t hang out at parties • I spend my day in a cave like room • Yes, I am an eHermit http://eHermitsInc.com INTRODUCTION
  • 5. BEFORE WE START TO PLAY • What is a plugin? • What can plugins do? • What do you need to know? • “But I heard plugins make your site slow!” • “But I heard that plugins make your site insecure!”
  • 6. PLUGIN SURVIVAL KIT • http://wordpress.org/plugins/ - Look for a plugin that is similar • http://wordpress.org/plugins/about/ - Describes how to create a plugin • http://codex.wordpress.org/ - Your guide • http://codex.wordpress.org/Writing_a_Plugin • http://codex.wordpress.org/Plugin_API/Action_Reference - When actions are called • http://codex.wordpress.org/Plugin_API/Filter_Reference - List of common Filters • http://themergency.com/generators/wordpress-plugin-boilerplate/ - Basics • http://generatewp.com/ - Helps add Features
  • 7. PLUGIN • A Plugin is a group of php functions that can extend the functionality present in a standard WordPress weblog. These functions may all be defined in one php file, or may be spread among more than one file. Usually, a plugin is a php file that can be uploaded to the "wp- content/plugins" directory on your webserver, where you have installed WordPress. Once you have uploaded the plugin file, you should be able to "turn it on" or Enable it from the "Plugins" page in the administration interface of your weblog. The WordPress source code contains hooks that can be used by plugins. • See also: Hack, Hacking • Related articles: Plugins http://codex.wordpress.org/Glossary
  • 8. HOOK • Hooks are specified, by the developer, in Actions and Filters. Here is a (hopefully) complete list of all existing Hooks within WordPress. Because Hooks are required by Actions and Filter you may hear the phrase "Action Hooks" and "Filter Hooks" used from time to time. In technical and strict terms: a Hook is an event, i.e. event as understood by Observer pattern, invoked by the do_action() orapply_filters() call that afterwards triggers all the action or filter functions, previously hooked to that event usingadd_action() or add_filter(), respectively. •See also: Action, Filter •Related articles: Hooks, Actions and Filters, Plugin API/Hooks http://codex.wordpress.org/Glossary
  • 9. FILTER In WordPress, a Filter is a function that is associated with an existing Action by specifying any existing Hook. Developers can create custom Filters using the Filter API to replace code from an existing Action. This process is called "hooking". Custom Filters differ from custom Actions because custom Actions allow you to add or remove code from existing Actions. Whereas custom Filters allow you to replace specific data (such as a variable) found within an existing Action. •See also: Action, Hook, Terminology Confusion •Related articles: Filters, Filter Reference, add_filter() http://codex.wordpress.org/Glossary
  • 10. ACTION • In WordPress; an Action is a PHP function that is executed at specific points throughout the WordPress Core. Developers can create a custom Action using the Action API to add or remove code from an existing Action by specifying any existing Hook. This process is called "hooking". For example: A developer may want to add code to the footer of a Theme. This could be accomplished by writing new function, then Hooking it to the wp_footer Action. Custom Actions differ from custom Filters because custom Actions allow you to add or remove code from existing Actions. Whereas custom Filters allow you to replace specific data (such as a variable) found within an existing Action. •See also: Filter, Hook, Terminology Confusion •Related articles: Actions, Action Reference, add_action() •Forum posts: Filters vs. Actions Discussion and Explanation http://codex.wordpress.org/Glossary
  • 11. OK – HOW ARE WE DOING?
  • 13. LET’S PLAY • We’re going to use the tools we have seen to create a plugin • Let’s mess with Dolly’s head a little bit • Using actions • Using filters • Including CSS • Including Scripts
  • 14. BRIAN DID MIRACULOUS STUFF YOU CAN’T SEE IN THE DOWNLOADED SLIDESHOW • Bet you wish you were at Ohio’s 2014 North Canton WordCamp • Then you could have seen us do all the fun stuff we did • We’re sorry you missed it • Maybe you can make it next year.. • OK next slide…
  • 15. FIGURING OUT WHERE YOU MESSED UP • http://codex.wordpress.org/Editing_wp-config.php @ini_set( 'log_errors', On' ); @ini_set( 'error_log', '/home/example/php_error.log' ); @ini_set( 'display_errors', 'On' ); @ini_set( 'error_reporting', E_ALL ); define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', false ); define( 'WP_DEBUG_DISPLAY', true );
  • 16. DOING THINGS RIGHT • Data Validation • https://codex.wordpress.org/Data_Validation • esc_attr, wp kses, esc_url • Use $wpdb for database access • get_var, get_row, insert, update, delete • Use prepare for custom queries • $wpdb->query( $wpdb->prepare(“select blah from foo where i= %d”, $myintvar )