SlideShare a Scribd company logo
1 of 28
Download to read offline
PLUGIN DEVELOPMENT
                          PRACTICES
    Presented By: Dan Pastori
          @danpastori           521 Dimensions
                                      TECHNOLGY SOLVING NEEDS




Sunday, June 3, 12
Dan Pastori

Sunday, June 3, 12
WHO IS DAN PASTORI?
                           Primary PHP/Java Developer

                          Co-Founded 521 Dimensions


                      Built two large plugins and one theme

                     Been tearing apart Wordpress for 3 years


Sunday, June 3, 12
OTHER PRODUCTS I’VE DEVELOPED FOR




                     And of course custom applications!

Sunday, June 3, 12
WORDPRESS IS THE BEST!
                         (at least from my experience!)

          Great Documentation


          Great Community


           Fast learning curve



Sunday, June 3, 12
PRE-REQUISITES
       Understanding of PHP



      Motivation/Consistency



      A goal to develop towards



Sunday, June 3, 12
WORDPRESS TERMINOLOGY
    2 Types of Hooks:

    1. Filter - Modifies text before it hits the screen.

    2. Action - Hooks launched during execution.




Sunday, June 3, 12
WHERE TO BEGIN?
          1. Find a need
          2. Focus on that need
          3. Prototype
          4. Jump right in

Sunday, June 3, 12
BEGIN YOUR PLUGIN




Sunday, June 3, 12
STRUCTURING PLUGIN
       Create Directories

                     /wp-content/plugins/[NAME]

                     /wp-content/plugins/[NAME]/css

                     /wp-content/plugins/[NAME]/js

                     /wp-content/plugins/[NAME]/images

                     /wp-content/plugins/[NAME]/includes

Sunday, June 3, 12
ADD MAIN FILE
                     /wp-content/plugins/[NAME]/[NAME].php




Sunday, June 3, 12
Add Header In Main File
                     /*
                     Plugin Name: [NAME]
                     Plugin URI: http://www.521dimensions.com/wp-pictures
                     Description: Pictures in Wordpress!
                     Version: 1.0
                     Author: Dan Pastori
                     Author URI: http://www.521dimensions.com
                     License: GPL2
                     */




Sunday, June 3, 12
OOP VS FUNCTIONAL?
                     Modern programming practices say OOP

                                  Both work!




Sunday, June 3, 12
BEGIN CODING!
                     DO NOT OVER-WRITE CORE FUNCTIONALITY


                     Use predefined functions as much as possible
                            (They’re there for a reason!)




Sunday, June 3, 12
What happens when you activate and
               deactivate?

         register_activation_hook(__FILE__, ‘function_name’)

         register_deactivation_hook(__FILE__, ‘function_name’)




Sunday, June 3, 12
Open [NAME].php

   OOP
   ...
   class WPPictures {
       static function install() {
             // do not generate any output here
       }
   }
   register_activation_hook( __FILE__, array('WPPictures', 'install') );


  Functional
   ...
   function wp_pictures_install(){

   }
   register_activation_hook( __FILE__, ‘wp_pictures_install’ );



Sunday, June 3, 12
WORKING WITH THE DATABASE
                     global $wpdb object


                         dbDelta()




Sunday, June 3, 12
INITIAL INSTALL
          1. Check for upgrades
              If {installed version} != {plugin version}
          2. Create Tables

          3. Set options




Sunday, June 3, 12
CSS AND JS
        Register first, enqueue second
       wp_register_script('product_js', plugins_url('/js/
       product_list.js', __FILE__));

      wp_enqueue_script('thickbox',null,array('jquery'));




Sunday, June 3, 12
DASHBOARD VISUAL APPEAL
                One management page, append to settings menu

               Multiple management pages, have it’s own heading




Sunday, June 3, 12
ADMIN MENUS
    add_menu_page(PAGE TITLE, MENU TITLE, PERMISSION, SLUG, FUNCTION, LOGO);

   add_submenu_page(PARENT SLUG, PAGE TITLE, MENU TITLE, 'CAPABILITY', 'MENU SLUG',
'FUNCTION');




Sunday, June 3, 12
MEDIA GALLERY
                     wp_insert_attachment($attachment, $filename,
                                    $parentPostID)




Sunday, June 3, 12
PERMISSIONS
                       current_user_can('manage_options')




               http://codex.wordpress.org/Roles_and_Capabilities

Sunday, June 3, 12
SHORTCODES
        add_shortcode('product-list', 'product_list_shortcode');

       extract( shortcode_atts( array(
                 'categoryID' => 'all',
                    ), $attributes ));




Sunday, June 3, 12
ENSURE PLUGIN QUALITY
                 Be accepting of criticism
                 DOCUMENT... PLEASE :)
                 Update
                 Don’t solve everything, do one thing right




Sunday, June 3, 12
BE THE SERVER ADMIN’S FRIEND
                     (And have a quality plugin)
       Minimize requests

       Make sure your resources are present

       Use common php packages

       Don’t require 777 on ANY directory!




Sunday, June 3, 12
LAUNCH PLUGIN
                        Have your Mom use your plugin


                             Accept criticism

                     Maintain thorough documentation




Sunday, June 3, 12
QUESTIONS?

                       @danpastori




Sunday, June 3, 12

More Related Content

Viewers also liked

My first 3 months working with word press
My first 3 months working with word pressMy first 3 months working with word press
My first 3 months working with word pressNoe Lopez
 
Open Source Entrepreneurship
Open Source EntrepreneurshipOpen Source Entrepreneurship
Open Source EntrepreneurshipJimmy Rosén
 
how to not design like a developer
how to not design like a developerhow to not design like a developer
how to not design like a developertracy apps
 
WordPress in a Time of Crisis
WordPress in a Time of CrisisWordPress in a Time of Crisis
WordPress in a Time of CrisisMichelle Amaral
 
Wc norrkoping-2015
Wc norrkoping-2015Wc norrkoping-2015
Wc norrkoping-2015pelmered
 
WordPress & eCommerce - WCLV 2011
WordPress & eCommerce - WCLV 2011WordPress & eCommerce - WCLV 2011
WordPress & eCommerce - WCLV 2011Shayne Sanderson
 
Optimizing Content Visibility (St. Louis WordCamp)
Optimizing Content Visibility (St. Louis WordCamp)Optimizing Content Visibility (St. Louis WordCamp)
Optimizing Content Visibility (St. Louis WordCamp)Teresa Lane
 
SEO para Wordpress (WordCamp Salvador)
SEO para Wordpress (WordCamp Salvador)SEO para Wordpress (WordCamp Salvador)
SEO para Wordpress (WordCamp Salvador)Ian Castro
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPresstopher1kenobe
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Konstantin Obenland
 
Customizing the custom loop wordcamp 2012-jeff
Customizing the custom loop   wordcamp 2012-jeffCustomizing the custom loop   wordcamp 2012-jeff
Customizing the custom loop wordcamp 2012-jeffAlexander Sapountzis
 
Customize your theme using css
Customize your theme using cssCustomize your theme using css
Customize your theme using cssMichael Arestad
 
Introducing the wpXtreme ecosystem
Introducing the wpXtreme ecosystemIntroducing the wpXtreme ecosystem
Introducing the wpXtreme ecosystemGGDBologna
 
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV GGDBologna
 
Leveraging Wordpress for an Ecommerce Website
Leveraging Wordpress for an Ecommerce WebsiteLeveraging Wordpress for an Ecommerce Website
Leveraging Wordpress for an Ecommerce WebsiteWill Hanke
 
Responsive Images (STL WordCamp 2014)
Responsive Images (STL WordCamp 2014)Responsive Images (STL WordCamp 2014)
Responsive Images (STL WordCamp 2014)joemcgill
 

Viewers also liked (16)

My first 3 months working with word press
My first 3 months working with word pressMy first 3 months working with word press
My first 3 months working with word press
 
Open Source Entrepreneurship
Open Source EntrepreneurshipOpen Source Entrepreneurship
Open Source Entrepreneurship
 
how to not design like a developer
how to not design like a developerhow to not design like a developer
how to not design like a developer
 
WordPress in a Time of Crisis
WordPress in a Time of CrisisWordPress in a Time of Crisis
WordPress in a Time of Crisis
 
Wc norrkoping-2015
Wc norrkoping-2015Wc norrkoping-2015
Wc norrkoping-2015
 
WordPress & eCommerce - WCLV 2011
WordPress & eCommerce - WCLV 2011WordPress & eCommerce - WCLV 2011
WordPress & eCommerce - WCLV 2011
 
Optimizing Content Visibility (St. Louis WordCamp)
Optimizing Content Visibility (St. Louis WordCamp)Optimizing Content Visibility (St. Louis WordCamp)
Optimizing Content Visibility (St. Louis WordCamp)
 
SEO para Wordpress (WordCamp Salvador)
SEO para Wordpress (WordCamp Salvador)SEO para Wordpress (WordCamp Salvador)
SEO para Wordpress (WordCamp Salvador)
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!
 
Customizing the custom loop wordcamp 2012-jeff
Customizing the custom loop   wordcamp 2012-jeffCustomizing the custom loop   wordcamp 2012-jeff
Customizing the custom loop wordcamp 2012-jeff
 
Customize your theme using css
Customize your theme using cssCustomize your theme using css
Customize your theme using css
 
Introducing the wpXtreme ecosystem
Introducing the wpXtreme ecosystemIntroducing the wpXtreme ecosystem
Introducing the wpXtreme ecosystem
 
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV
Responsività e integrazioni social: l’utente al centro nel nuovo sito Volvo TV
 
Leveraging Wordpress for an Ecommerce Website
Leveraging Wordpress for an Ecommerce WebsiteLeveraging Wordpress for an Ecommerce Website
Leveraging Wordpress for an Ecommerce Website
 
Responsive Images (STL WordCamp 2014)
Responsive Images (STL WordCamp 2014)Responsive Images (STL WordCamp 2014)
Responsive Images (STL WordCamp 2014)
 

Similar to Wordpress Plugin Development Practices

Introduction to Twig
Introduction to TwigIntroduction to Twig
Introduction to Twigmarkstory
 
Dapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal ThemesDapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal Themeskilltheliterate
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practicesdanpastori
 
Wordpress bb-portland
Wordpress bb-portlandWordpress bb-portland
Wordpress bb-portlandAllenSnook
 
Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013   Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013 Pablo Godel
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projectsVincent Massol
 
3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)drupalconf
 
Passing a Front end Developer interview
Passing a Front end Developer interview Passing a Front end Developer interview
Passing a Front end Developer interview tonyfarnsworth
 
Lone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AngleLone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AnglePablo Godel
 
Unit Testing in SilverStripe
Unit Testing in SilverStripeUnit Testing in SilverStripe
Unit Testing in SilverStripeIngo Schommer
 
Pundit
PunditPundit
PunditNet7
 
Drupal for Project Managers, Part 3: Launching
Drupal for Project Managers, Part 3: LaunchingDrupal for Project Managers, Part 3: Launching
Drupal for Project Managers, Part 3: LaunchingAcquia
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.Arshak Movsisyan
 
TripCase Unit Testing with Jasmine
TripCase Unit Testing with JasmineTripCase Unit Testing with Jasmine
TripCase Unit Testing with JasmineStephen Pond
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben Speakmon
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben SpeakmonAtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben Speakmon
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben SpeakmonAtlassian
 
Drupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupalMumbai
 
What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...Richard McIntyre
 

Similar to Wordpress Plugin Development Practices (20)

Introduction to Twig
Introduction to TwigIntroduction to Twig
Introduction to Twig
 
Dapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal ThemesDapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal Themes
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practices
 
Wordpress bb-portland
Wordpress bb-portlandWordpress bb-portland
Wordpress bb-portland
 
Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013   Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projects
 
3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)
 
Passing a Front end Developer interview
Passing a Front end Developer interview Passing a Front end Developer interview
Passing a Front end Developer interview
 
Fork cli tool
Fork cli toolFork cli tool
Fork cli tool
 
Lone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AngleLone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New Angle
 
Lightweight javaEE with Guice
Lightweight javaEE with GuiceLightweight javaEE with Guice
Lightweight javaEE with Guice
 
Unit Testing in SilverStripe
Unit Testing in SilverStripeUnit Testing in SilverStripe
Unit Testing in SilverStripe
 
Pundit
PunditPundit
Pundit
 
Drupal for Project Managers, Part 3: Launching
Drupal for Project Managers, Part 3: LaunchingDrupal for Project Managers, Part 3: Launching
Drupal for Project Managers, Part 3: Launching
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.
 
TripCase Unit Testing with Jasmine
TripCase Unit Testing with JasmineTripCase Unit Testing with Jasmine
TripCase Unit Testing with Jasmine
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben Speakmon
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben SpeakmonAtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben Speakmon
AtlasCamp 2010: The Atlassian Plugin SDK For Fun & Profit - Ben Speakmon
 
Drupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj K
 
What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...
 

Recently uploaded

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
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
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
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
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Wordpress Plugin Development Practices

  • 1. PLUGIN DEVELOPMENT PRACTICES Presented By: Dan Pastori @danpastori 521 Dimensions TECHNOLGY SOLVING NEEDS Sunday, June 3, 12
  • 3. WHO IS DAN PASTORI? Primary PHP/Java Developer Co-Founded 521 Dimensions Built two large plugins and one theme Been tearing apart Wordpress for 3 years Sunday, June 3, 12
  • 4. OTHER PRODUCTS I’VE DEVELOPED FOR And of course custom applications! Sunday, June 3, 12
  • 5. WORDPRESS IS THE BEST! (at least from my experience!) Great Documentation Great Community Fast learning curve Sunday, June 3, 12
  • 6. PRE-REQUISITES Understanding of PHP Motivation/Consistency A goal to develop towards Sunday, June 3, 12
  • 7. WORDPRESS TERMINOLOGY 2 Types of Hooks: 1. Filter - Modifies text before it hits the screen. 2. Action - Hooks launched during execution. Sunday, June 3, 12
  • 8. WHERE TO BEGIN? 1. Find a need 2. Focus on that need 3. Prototype 4. Jump right in Sunday, June 3, 12
  • 10. STRUCTURING PLUGIN Create Directories /wp-content/plugins/[NAME] /wp-content/plugins/[NAME]/css /wp-content/plugins/[NAME]/js /wp-content/plugins/[NAME]/images /wp-content/plugins/[NAME]/includes Sunday, June 3, 12
  • 11. ADD MAIN FILE /wp-content/plugins/[NAME]/[NAME].php Sunday, June 3, 12
  • 12. Add Header In Main File /* Plugin Name: [NAME] Plugin URI: http://www.521dimensions.com/wp-pictures Description: Pictures in Wordpress! Version: 1.0 Author: Dan Pastori Author URI: http://www.521dimensions.com License: GPL2 */ Sunday, June 3, 12
  • 13. OOP VS FUNCTIONAL? Modern programming practices say OOP Both work! Sunday, June 3, 12
  • 14. BEGIN CODING! DO NOT OVER-WRITE CORE FUNCTIONALITY Use predefined functions as much as possible (They’re there for a reason!) Sunday, June 3, 12
  • 15. What happens when you activate and deactivate? register_activation_hook(__FILE__, ‘function_name’) register_deactivation_hook(__FILE__, ‘function_name’) Sunday, June 3, 12
  • 16. Open [NAME].php OOP ... class WPPictures { static function install() { // do not generate any output here } } register_activation_hook( __FILE__, array('WPPictures', 'install') ); Functional ... function wp_pictures_install(){ } register_activation_hook( __FILE__, ‘wp_pictures_install’ ); Sunday, June 3, 12
  • 17. WORKING WITH THE DATABASE global $wpdb object dbDelta() Sunday, June 3, 12
  • 18. INITIAL INSTALL 1. Check for upgrades If {installed version} != {plugin version} 2. Create Tables 3. Set options Sunday, June 3, 12
  • 19. CSS AND JS Register first, enqueue second wp_register_script('product_js', plugins_url('/js/ product_list.js', __FILE__)); wp_enqueue_script('thickbox',null,array('jquery')); Sunday, June 3, 12
  • 20. DASHBOARD VISUAL APPEAL One management page, append to settings menu Multiple management pages, have it’s own heading Sunday, June 3, 12
  • 21. ADMIN MENUS add_menu_page(PAGE TITLE, MENU TITLE, PERMISSION, SLUG, FUNCTION, LOGO); add_submenu_page(PARENT SLUG, PAGE TITLE, MENU TITLE, 'CAPABILITY', 'MENU SLUG', 'FUNCTION'); Sunday, June 3, 12
  • 22. MEDIA GALLERY wp_insert_attachment($attachment, $filename, $parentPostID) Sunday, June 3, 12
  • 23. PERMISSIONS current_user_can('manage_options') http://codex.wordpress.org/Roles_and_Capabilities Sunday, June 3, 12
  • 24. SHORTCODES add_shortcode('product-list', 'product_list_shortcode'); extract( shortcode_atts( array( 'categoryID' => 'all', ), $attributes )); Sunday, June 3, 12
  • 25. ENSURE PLUGIN QUALITY Be accepting of criticism DOCUMENT... PLEASE :) Update Don’t solve everything, do one thing right Sunday, June 3, 12
  • 26. BE THE SERVER ADMIN’S FRIEND (And have a quality plugin) Minimize requests Make sure your resources are present Use common php packages Don’t require 777 on ANY directory! Sunday, June 3, 12
  • 27. LAUNCH PLUGIN Have your Mom use your plugin Accept criticism Maintain thorough documentation Sunday, June 3, 12
  • 28. QUESTIONS? @danpastori Sunday, June 3, 12