SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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 Processorsdebabhi2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

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