SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Writing Your First WordPress Plugin or, What I wish someone had told me because it would have prevented me from banging my head on the desk a lot Boone Gorges @boonebgorges [email_address] http://teleogistic.net
Who am I? – early 2009 ,[object Object],[object Object],[object Object],[object Object]
Who am I? – early 2010 ,[object Object],[object Object],[object Object]
1) The structure of WordPress
WordPress is modular Separable pieces: classes, functions, template files Serial: Everything happens in a certain order
WordPress is modular Plugins : New classes, functions, or template files that either replace or augment WP “core”
2) Plugin basics
Where do plugins live? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Let WP know you exist <?php /* Plugin Name: Boone’s Plugin Plugin URI: http://teleogistic.net Description: This plugin will blow your mind Author: boonebgorges Version: 1.0 Author URI: http://teleogistic.net */ wp-content/plugins/boones-plugin/boones-plugin.php See  http://codex.wordpress.org/Writing_a_Plugin#File_Headers
3) Example: Shortcode
Shortcodes fill in for frequently-typed stuff Say you typed your address a lot:
The WordPress Shortcode API function address_shortcode() { return '<p>Boone Gorges<br /> 24 Gumdrop Lane<br /> Apartment #32<br /> Sugarlove, MD 20020</p>'; } add_shortcode( 'bgaddress', 'address_shortcode' ); wp-content/plugins/boones-plugin/boones-plugin.php See  http://codex.wordpress.org/Shortcode_API
Soup that baby up function address_shortcode($atts) { extract(shortcode_atts(array( 'location' => 'MD' ), $atts)); if ( $atts['location'] == 'MD' )   return '<p>Boone Gorges<br /> 24 Gumdrop Lane<br /> Apartment   #32<br /> Sugarlove, MD 20020</p>'; else   return '<p>Boone Gorges<br /> 85 Lollipop Street<br />  Apartment   #81<br /> Milwaukee, WI 54112</p>'; } add_shortcode( 'bgaddress', 'address_shortcode' ); wp-content/plugins/boones-plugin/boones-plugin.php See  http://codex.wordpress.org/Shortcode_API
There's a Widgets API too See  http://codex.wordpress.org/Widgets_API
4) Example: Hooks
Actions are hooks In the core: do_action( 'loop_start' ); In your plugin: add_action( 'loop_start', 'my_code' );
Example: A hello message  function well_hello_there() { global $user_identity; if ( is_user_logged_in() ) echo &quot;Welcome, &quot; . $user_identity; else echo &quot;Welcome, anonymous lurker!&quot;; }  add_action( 'loop_start', 'well_hello_there' );  wp-content/plugins/boones-plugin/boones-plugin.php See  http://codex.wordpress.org/Plugin_API/Action_Reference
Filters are hooks… with benefits In the core: $content = apply_filters('the_content', $content); In your plugin: add_filter( 'the_content', 'my_code' );
Example: Makin' it 1337  function make_it_leet( $content ) { $leet_content = str_replace( 'e', '3', $content ); return $leet_content; }  add_filter( 'the_content', 'make_it_leet' ); wp-content/plugins/boones-plugin/boones-plugin.php See  http://codex.wordpress.org/Plugin_API/Filter_Reference
5) The plugin dev's toolbox
Resources on the web The WordPress Codex, especially: -  http://codex.wordpress.org/Shortcode_API   -  http://codex.wordpress.org/Widgets_API -  http://codex.wordpress.org/Plugin_API The WordPress PHP Cross-Reference -  http://xref.yoast.com The WordPress plugin repository: -  http://wordpress.org/extend/plugins  to download -  http://wordpress.org/extend/plugins/about  to add your own plugin PHP resources - W3Schools –  http://www.w3schools.com/PHP/ - php.net –  http://www.php.net/manual/en
Resources on your computer A good text editor, ideally one with - the ability to save over FTP - good search-and-replace - code highlighting - see  http://lifehacker.com/385929/best-text-editors  for suggestions A local development environment - AMP: Apache, MySQL, PHP - Windows: XAMPP; Mac: MAMP - Use SVN to get the most recent copies of WordPress
Words of advice The White Screen Of Death - Usually means you have a syntax error (check your punctuation!) - No duplicate function names, except for functions in pluggable.php - Use  if ( function_exists( 'my_function' ) ) Get to know your data - Learn about globals:  $wp, $post, $comment -  var_dump( $wp ); -  print &quot;<pre>&quot;; print_r( $wp ); print &quot;</pre>&quot;; -  die(); Pick apart existing plugins Ask for help:  http://wordpress.org/support
Booyah! Boone Gorges @boonebgorges [email_address] http://teleogistic.net

Weitere ähnliche Inhalte

Was ist angesagt?

Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Webjoelburton
 
הרצאה מתוקשבת וורדפרס מתקדם
הרצאה מתוקשבת וורדפרס מתקדםהרצאה מתוקשבת וורדפרס מתקדם
הרצאה מתוקשבת וורדפרס מתקדםShirly Kamusher
 
1111הרצאה וורדפרס מתקדם
1111הרצאה וורדפרס מתקדם1111הרצאה וורדפרס מתקדם
1111הרצאה וורדפרס מתקדםShirly Kamusher
 
WordPress SEO - SEO-Campixx
WordPress SEO - SEO-CampixxWordPress SEO - SEO-Campixx
WordPress SEO - SEO-Campixxsteffenhd
 
Charisma Productions Network - Tutorial: Google for Webmasters
Charisma Productions Network - Tutorial: Google for WebmastersCharisma Productions Network - Tutorial: Google for Webmasters
Charisma Productions Network - Tutorial: Google for WebmastersBetty Andrews
 
Search Engine Optimization Tools - Tutorial: Google for Webmaster
Search Engine Optimization Tools - Tutorial: Google for WebmasterSearch Engine Optimization Tools - Tutorial: Google for Webmaster
Search Engine Optimization Tools - Tutorial: Google for WebmasterPraveen Sudarsan
 
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for Webmasters
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for WebmastersGRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for Webmasters
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for WebmastersEdysur Construcciones
 
Alternative Design Workflows in a "PostPSD" Era
Alternative Design Workflows in a "PostPSD" EraAlternative Design Workflows in a "PostPSD" Era
Alternative Design Workflows in a "PostPSD" EraJeremy Fuksa
 
開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版Kyle Lin
 
New Search Strategies
New Search StrategiesNew Search Strategies
New Search Strategiesnotess
 
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011Kathryn Presner
 
Session 3 using search engines
Session 3   using search enginesSession 3   using search engines
Session 3 using search enginesGrow_ZA
 
Social Media Marketing for the Lean Startup
Social Media Marketing for the Lean StartupSocial Media Marketing for the Lean Startup
Social Media Marketing for the Lean StartupEric Krock
 

Was ist angesagt? (16)

Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Web
 
C 2
C 2C 2
C 2
 
הרצאה מתוקשבת וורדפרס מתקדם
הרצאה מתוקשבת וורדפרס מתקדםהרצאה מתוקשבת וורדפרס מתקדם
הרצאה מתוקשבת וורדפרס מתקדם
 
1111הרצאה וורדפרס מתקדם
1111הרצאה וורדפרס מתקדם1111הרצאה וורדפרס מתקדם
1111הרצאה וורדפרס מתקדם
 
WordPress SEO - SEO-Campixx
WordPress SEO - SEO-CampixxWordPress SEO - SEO-Campixx
WordPress SEO - SEO-Campixx
 
Charisma Productions Network - Tutorial: Google for Webmasters
Charisma Productions Network - Tutorial: Google for WebmastersCharisma Productions Network - Tutorial: Google for Webmasters
Charisma Productions Network - Tutorial: Google for Webmasters
 
Search Engine Optimization Tools - Tutorial: Google for Webmaster
Search Engine Optimization Tools - Tutorial: Google for WebmasterSearch Engine Optimization Tools - Tutorial: Google for Webmaster
Search Engine Optimization Tools - Tutorial: Google for Webmaster
 
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for Webmasters
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for WebmastersGRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for Webmasters
GRUPO CONSTRUCTOR MIAHUATLAN - Tutorial: Google for Webmasters
 
Session no 1
Session no 1Session no 1
Session no 1
 
Alternative Design Workflows in a "PostPSD" Era
Alternative Design Workflows in a "PostPSD" EraAlternative Design Workflows in a "PostPSD" Era
Alternative Design Workflows in a "PostPSD" Era
 
開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版
 
New Search Strategies
New Search StrategiesNew Search Strategies
New Search Strategies
 
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
 
Session 3 using search engines
Session 3   using search enginesSession 3   using search engines
Session 3 using search engines
 
Blogs and RSS Feeds
Blogs and RSS FeedsBlogs and RSS Feeds
Blogs and RSS Feeds
 
Social Media Marketing for the Lean Startup
Social Media Marketing for the Lean StartupSocial Media Marketing for the Lean Startup
Social Media Marketing for the Lean Startup
 

Ähnlich wie Write Your First WordPress Plugin

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 WorkshopBrendan Sera-Shriar
 
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 2008Brendan Sera-Shriar
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentAizat Faiz
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress DevelopmentAndy Brudtkuhl
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsTomAuger
 
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 InstituteBrendan Sera-Shriar
 
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)Jon Peck
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPressLester Chan
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Jamie Oastler
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTYWilliam Chong
 
Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPrandyhoyt
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 Evan Mullins
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPandrewnacin
 
Developing WordPress Plugins
Developing WordPress PluginsDeveloping WordPress Plugins
Developing WordPress Pluginsrebelpixel
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp HamiltonPaul Bearne
 

Ähnlich wie Write Your First WordPress Plugin (20)

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
 
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
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress Development
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
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
 
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
 
Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHP
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHP
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
Developing WordPress Plugins
Developing WordPress PluginsDeveloping WordPress Plugins
Developing WordPress Plugins
 
Optimize wordpress
Optimize wordpressOptimize wordpress
Optimize wordpress
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
 

Kürzlich hochgeladen

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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
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
 
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
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
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
 
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!
 
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.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Write Your First WordPress Plugin

  • 1. Writing Your First WordPress Plugin or, What I wish someone had told me because it would have prevented me from banging my head on the desk a lot Boone Gorges @boonebgorges [email_address] http://teleogistic.net
  • 2.
  • 3.
  • 4. 1) The structure of WordPress
  • 5. WordPress is modular Separable pieces: classes, functions, template files Serial: Everything happens in a certain order
  • 6. WordPress is modular Plugins : New classes, functions, or template files that either replace or augment WP “core”
  • 8.
  • 9. Let WP know you exist <?php /* Plugin Name: Boone’s Plugin Plugin URI: http://teleogistic.net Description: This plugin will blow your mind Author: boonebgorges Version: 1.0 Author URI: http://teleogistic.net */ wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Writing_a_Plugin#File_Headers
  • 11. Shortcodes fill in for frequently-typed stuff Say you typed your address a lot:
  • 12. The WordPress Shortcode API function address_shortcode() { return '<p>Boone Gorges<br /> 24 Gumdrop Lane<br /> Apartment #32<br /> Sugarlove, MD 20020</p>'; } add_shortcode( 'bgaddress', 'address_shortcode' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Shortcode_API
  • 13. Soup that baby up function address_shortcode($atts) { extract(shortcode_atts(array( 'location' => 'MD' ), $atts)); if ( $atts['location'] == 'MD' ) return '<p>Boone Gorges<br /> 24 Gumdrop Lane<br /> Apartment #32<br /> Sugarlove, MD 20020</p>'; else return '<p>Boone Gorges<br /> 85 Lollipop Street<br /> Apartment #81<br /> Milwaukee, WI 54112</p>'; } add_shortcode( 'bgaddress', 'address_shortcode' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Shortcode_API
  • 14. There's a Widgets API too See http://codex.wordpress.org/Widgets_API
  • 16. Actions are hooks In the core: do_action( 'loop_start' ); In your plugin: add_action( 'loop_start', 'my_code' );
  • 17. Example: A hello message function well_hello_there() { global $user_identity; if ( is_user_logged_in() ) echo &quot;Welcome, &quot; . $user_identity; else echo &quot;Welcome, anonymous lurker!&quot;; } add_action( 'loop_start', 'well_hello_there' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Plugin_API/Action_Reference
  • 18. Filters are hooks… with benefits In the core: $content = apply_filters('the_content', $content); In your plugin: add_filter( 'the_content', 'my_code' );
  • 19. Example: Makin' it 1337 function make_it_leet( $content ) { $leet_content = str_replace( 'e', '3', $content ); return $leet_content; } add_filter( 'the_content', 'make_it_leet' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Plugin_API/Filter_Reference
  • 20. 5) The plugin dev's toolbox
  • 21. Resources on the web The WordPress Codex, especially: - http://codex.wordpress.org/Shortcode_API - http://codex.wordpress.org/Widgets_API - http://codex.wordpress.org/Plugin_API The WordPress PHP Cross-Reference - http://xref.yoast.com The WordPress plugin repository: - http://wordpress.org/extend/plugins to download - http://wordpress.org/extend/plugins/about to add your own plugin PHP resources - W3Schools – http://www.w3schools.com/PHP/ - php.net – http://www.php.net/manual/en
  • 22. Resources on your computer A good text editor, ideally one with - the ability to save over FTP - good search-and-replace - code highlighting - see http://lifehacker.com/385929/best-text-editors for suggestions A local development environment - AMP: Apache, MySQL, PHP - Windows: XAMPP; Mac: MAMP - Use SVN to get the most recent copies of WordPress
  • 23. Words of advice The White Screen Of Death - Usually means you have a syntax error (check your punctuation!) - No duplicate function names, except for functions in pluggable.php - Use if ( function_exists( 'my_function' ) ) Get to know your data - Learn about globals: $wp, $post, $comment - var_dump( $wp ); - print &quot;<pre>&quot;; print_r( $wp ); print &quot;</pre>&quot;; - die(); Pick apart existing plugins Ask for help: http://wordpress.org/support
  • 24. Booyah! Boone Gorges @boonebgorges [email_address] http://teleogistic.net