SlideShare une entreprise Scribd logo
1  sur  17
Creating Your First
WordPress Plugin
      Colin Loretz
Why?
codex.wordpress.org
        Know it

       Breathe it

        Live it
Anatomy of a Plugin
  Plugin Folder Name
   • main php file
   • js folder
   • css folder
   • php folder
Anatomy of a Plugin
  reno-wordcamp
    • reno-wordcamp.php
    • js
    • css
    • php
Main PHP File
<?php
/*
Plugin Name: Your Plugin Name Here
Plugin URI: Your Plugin URI
Version: Current Plugin Version
Author: You
Description: What does this do?
*/
reno-wordcamp.php
<?php
/*
Plugin Name: Reno WordCamp
Plugin URI: http://renotahoewordcamp.com
Version: v1.0
Author: <a href = “http://colinloretz.com”>Colin Loretz</a>
Description: A plugin for Reno WordCamp
*/
Adding an Action

  function addHeaderCode() {
    echo ʻHello from the clouds!ʼ;
  }
Actions & Filters

 //Actions
 add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1);


?>
Adding a Filter

function addContent($content=ʼʼ) {
  $content .= ʻ<p>Colin is at WordCamp.</p>ʼ;
  return $content;
}
Actions & Filters

 //Actions
 add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1);
 //Filters
 add_filter(ʻthe_contentʼ, ʻaddContentʼ);

?>
Adding a Shortcode


    [renowordcamp]
Adding a Shortcode
  function renoShortcode($att) {
  
  extract(shortcode_atts(array(
  
  
 'foo' => 'no foo',
  
  
 'bar' => 'default bar',
  
  ), $atts));

  
   
   return quot;foo = {$foo}quot;;
  }
Add the Shortcode
 //Actions
 add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1);
 //Filters
 add_filter(ʻthe_contentʼ, ʻaddContentʼ);
 //Shortcodes
 add_shortcode('renowordcamp', 'renoShortcode');
Going Further

Saving & Storing   Explore Plugins
                     Learn from others
  Options

  Post Metadata

  Database
Want More?

• Wordpress.org (and codex)
• WP-Hacker email list (google it)
• WordPress Planet
Find Me

   @colinloretz


www.colinloretz.com

Contenu connexe

Tendances

Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
techmemo
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009
Yusuke Wada
 

Tendances (20)

Web Audio API + AngularJS
Web Audio API + AngularJSWeb Audio API + AngularJS
Web Audio API + AngularJS
 
Five events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should knowFive events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should know
 
Modern Perl Toolchain
Modern Perl ToolchainModern Perl Toolchain
Modern Perl Toolchain
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Scratching the surface of hunky-dory Elixir features
Scratching the surface of hunky-dory Elixir featuresScratching the surface of hunky-dory Elixir features
Scratching the surface of hunky-dory Elixir features
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
 
Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"
 
Build a bot workshop async primer - php[tek]
Build a bot workshop  async primer - php[tek]Build a bot workshop  async primer - php[tek]
Build a bot workshop async primer - php[tek]
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Selenium sandwich-2
Selenium sandwich-2Selenium sandwich-2
Selenium sandwich-2
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
Web Scraping
Web ScrapingWeb Scraping
Web Scraping
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 

Similaire à Creating Your First WordPress Plugin

course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
webhostingguy
 

Similaire à Creating Your First WordPress Plugin (20)

Actions filters
Actions filtersActions filters
Actions filters
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPress
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
August 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle TwitterAugust 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle Twitter
 
FVCP - Facebook , Twitter and Meetup API / Widgets
FVCP - Facebook , Twitter and Meetup API / WidgetsFVCP - Facebook , Twitter and Meetup API / Widgets
FVCP - Facebook , Twitter and Meetup API / Widgets
 
Spyware/Malware FVCP
Spyware/Malware  FVCPSpyware/Malware  FVCP
Spyware/Malware FVCP
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Writing Pluggable Software
Writing Pluggable SoftwareWriting Pluggable Software
Writing Pluggable Software
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Php
PhpPhp
Php
 
09 Oo Php Register
09 Oo Php Register09 Oo Php Register
09 Oo Php Register
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Workshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfastWorkshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfast
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

Plus de Colin Loretz

Plus de Colin Loretz (14)

HTML & CSS 2017
HTML & CSS 2017HTML & CSS 2017
HTML & CSS 2017
 
Controlling Robots with Javascript, Ruby and Go
Controlling Robots with Javascript, Ruby and GoControlling Robots with Javascript, Ruby and Go
Controlling Robots with Javascript, Ruby and Go
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSS
 
Making Things Happen
Making Things HappenMaking Things Happen
Making Things Happen
 
Building App Themes for WordPress
Building App Themes for WordPressBuilding App Themes for WordPress
Building App Themes for WordPress
 
Zen of WordPress
Zen of WordPressZen of WordPress
Zen of WordPress
 
Steps to Open the Reno Makerspace
Steps to Open the Reno Makerspace Steps to Open the Reno Makerspace
Steps to Open the Reno Makerspace
 
Reno Collective Coworking
Reno Collective CoworkingReno Collective Coworking
Reno Collective Coworking
 
WordCamp Las Vegas: Your App is in my WordPress
WordCamp Las Vegas: Your App is in my WordPressWordCamp Las Vegas: Your App is in my WordPress
WordCamp Las Vegas: Your App is in my WordPress
 
WordPress as a CMS
WordPress as a CMSWordPress as a CMS
WordPress as a CMS
 
50 Apps to Fuel Your Online Business
50 Apps to Fuel Your Online Business50 Apps to Fuel Your Online Business
50 Apps to Fuel Your Online Business
 
Ignite Reno: Diagnosing Technology as a Mental Disorder
Ignite Reno: Diagnosing Technology as a Mental DisorderIgnite Reno: Diagnosing Technology as a Mental Disorder
Ignite Reno: Diagnosing Technology as a Mental Disorder
 
Adobe Flex: Creating Widgets for the Desktop and Web
Adobe Flex: Creating Widgets for the Desktop and WebAdobe Flex: Creating Widgets for the Desktop and Web
Adobe Flex: Creating Widgets for the Desktop and Web
 
Share an internet connection through WiFi [Mac OS X[
Share an internet connection through WiFi [Mac OS X[Share an internet connection through WiFi [Mac OS X[
Share an internet connection through WiFi [Mac OS X[
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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...
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Creating Your First WordPress Plugin

  • 1. Creating Your First WordPress Plugin Colin Loretz
  • 3. codex.wordpress.org Know it Breathe it Live it
  • 4. Anatomy of a Plugin Plugin Folder Name • main php file • js folder • css folder • php folder
  • 5. Anatomy of a Plugin reno-wordcamp • reno-wordcamp.php • js • css • php
  • 6. Main PHP File <?php /* Plugin Name: Your Plugin Name Here Plugin URI: Your Plugin URI Version: Current Plugin Version Author: You Description: What does this do? */
  • 7. reno-wordcamp.php <?php /* Plugin Name: Reno WordCamp Plugin URI: http://renotahoewordcamp.com Version: v1.0 Author: <a href = “http://colinloretz.com”>Colin Loretz</a> Description: A plugin for Reno WordCamp */
  • 8. Adding an Action function addHeaderCode() { echo ʻHello from the clouds!ʼ; }
  • 9. Actions & Filters //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); ?>
  • 10. Adding a Filter function addContent($content=ʼʼ) { $content .= ʻ<p>Colin is at WordCamp.</p>ʼ; return $content; }
  • 11. Actions & Filters //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); //Filters add_filter(ʻthe_contentʼ, ʻaddContentʼ); ?>
  • 12. Adding a Shortcode [renowordcamp]
  • 13. Adding a Shortcode function renoShortcode($att) { extract(shortcode_atts(array( 'foo' => 'no foo', 'bar' => 'default bar', ), $atts)); return quot;foo = {$foo}quot;; }
  • 14. Add the Shortcode //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); //Filters add_filter(ʻthe_contentʼ, ʻaddContentʼ); //Shortcodes add_shortcode('renowordcamp', 'renoShortcode');
  • 15. Going Further Saving & Storing Explore Plugins Learn from others Options Post Metadata Database
  • 16. Want More? • Wordpress.org (and codex) • WP-Hacker email list (google it) • WordPress Planet
  • 17. Find Me @colinloretz www.colinloretz.com

Notes de l'éditeur