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 Wordpress Meetup 2 23 10

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 Wordpress Meetup 2 23 10 (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

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
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.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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...DianaGray10
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
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 TerraformAndrey Devyatkin
 
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, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

Wordpress Meetup 2 23 10

  • 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