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
 

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
 
Html5 apis
Html5 apisHtml5 apis
Html5 apis
 
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
 

Recently uploaded

Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfOverkill Security
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 

Recently uploaded (20)

Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 

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