CSI:
Getting Into the Guts

WordCamp Birmingham, January 14, 2012
CSI:
Getting Into the Guts

WordCamp Birmingham, January 14, 2012
Version 0.5

   Please note that due to unforeseen events, I did not
    complete this slide deck to my satisfaction before
        presenting it at WordCamp Birmingham.

  I will be doing this presentation again at WordCamp
Atlanta, with an improved version of these slides. At that
    time, I will replace this presentation with the new,
   improved version which will contain more concrete
     developer information, code samples, and more
           comprehensive pointers to resources.

          Thank you for your understanding.

                                                 -- Dougal
WordPress
Rocks!
WordPress
Rocks!
Why?
Extensibility
WordPress can do just about any
freaking thing you can think of
Extensibility
Extensibility



✤   Rich developer APIs
Extensibility



✤   Rich developer APIs

✤   Themes
Extensibility



✤   Rich developer APIs

✤   Themes

✤   Plugins
API
API


✤   Application Programming
    Interface
API


✤   Application Programming
    Interface

✤   “...a source code based
    specification intended to be
    used as an interface by
    software components to
    communicate with each
    other.” – Wikipedia
What kind of APIs?

✤   Pluggable functions

✤   Hooks

    ✤   Actions and Filters

✤   Metadata

    ✤   Post meta, User meta, Comment meta, Site Options

✤   Custom Javascript and CSS
Pluggable
Functions
Login/Cookie/User info
Email notifications, wp_mail()
Security: nonces, password salts &
hashes
Avatars
Display of revision diffs
Themes


✤   Sidebars and Widgets

✤   Custom Headers and
    Backgrounds

✤   Custom Post Types and
    Taxonomies
Plugins
Plugins

✤   Plugins can do... practically anything:
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
    ✤   Extend user info
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
    ✤   Extend user info
    ✤   Use Roles & Capabilities to control access to features
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
    ✤   Extend user info
    ✤   Use Roles & Capabilities to control access to features
    ✤   Create workflows (e.g., EditFlow plugin)
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
    ✤   Extend user info
    ✤   Use Roles & Capabilities to control access to features
    ✤   Create workflows (e.g., EditFlow plugin)
    ✤   Alternative login systems (LDAP, SSO)
Plugins

✤   Plugins can do... practically anything:

    ✤   Modify posts/pages
    ✤   Integrate 3rd party data (Twitter, Facebook, etc.)
    ✤   Extend user info
    ✤   Use Roles & Capabilities to control access to features
    ✤   Create workflows (e.g., EditFlow plugin)
    ✤   Alternative login systems (LDAP, SSO)
    ✤   The sky’s the limit!
Actions
Actions are events


Use them to DO something, rather
than to CHANGE something
Actions
plugins_loaded()
setup_theme()
wp_init()
template_redirect()
wp_head()
wp_footer()
                      http://andy.wordpress.com/2008/10/30/wordpress-include-stack/
Filters
Modify existing content

<?php
add_filter( ‘the_content’, ‘lolify’ );


function lolify( $text_in ) {
     $text out = do_cool_stuff( $text_in );
     return $text_out;
}
?>
Metadata
Lets you add additional details beyond
what WordPress provides out-of-the-
box.
Metadata



✤   “Data about Data”

Lets you provide additional
details that may or may not be
visible on the site.
Putting it
together


✤   codex.wordpress.org

✤   make.wordpress.org

✤   wpdevel.wordpress.com
Who are you?


Dougal Campbell

@dougal

dougal.us /
dougal.gunters.org

dougal.campbell@gmail.com

CSI: WordPress -- Getting Into the Guts

  • 1.
    CSI: Getting Into theGuts WordCamp Birmingham, January 14, 2012
  • 2.
    CSI: Getting Into theGuts WordCamp Birmingham, January 14, 2012
  • 3.
    Version 0.5 Please note that due to unforeseen events, I did not complete this slide deck to my satisfaction before presenting it at WordCamp Birmingham. I will be doing this presentation again at WordCamp Atlanta, with an improved version of these slides. At that time, I will replace this presentation with the new, improved version which will contain more concrete developer information, code samples, and more comprehensive pointers to resources. Thank you for your understanding. -- Dougal
  • 4.
  • 5.
  • 6.
    Extensibility WordPress can dojust about any freaking thing you can think of
  • 7.
  • 8.
    Extensibility ✤ Rich developer APIs
  • 9.
    Extensibility ✤ Rich developer APIs ✤ Themes
  • 10.
    Extensibility ✤ Rich developer APIs ✤ Themes ✤ Plugins
  • 11.
  • 12.
    API ✤ Application Programming Interface
  • 13.
    API ✤ Application Programming Interface ✤ “...a source code based specification intended to be used as an interface by software components to communicate with each other.” – Wikipedia
  • 14.
    What kind ofAPIs? ✤ Pluggable functions ✤ Hooks ✤ Actions and Filters ✤ Metadata ✤ Post meta, User meta, Comment meta, Site Options ✤ Custom Javascript and CSS
  • 15.
    Pluggable Functions Login/Cookie/User info Email notifications,wp_mail() Security: nonces, password salts & hashes Avatars Display of revision diffs
  • 16.
    Themes ✤ Sidebars and Widgets ✤ Custom Headers and Backgrounds ✤ Custom Post Types and Taxonomies
  • 17.
  • 18.
    Plugins ✤ Plugins can do... practically anything:
  • 19.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages
  • 20.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.)
  • 21.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.) ✤ Extend user info
  • 22.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.) ✤ Extend user info ✤ Use Roles & Capabilities to control access to features
  • 23.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.) ✤ Extend user info ✤ Use Roles & Capabilities to control access to features ✤ Create workflows (e.g., EditFlow plugin)
  • 24.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.) ✤ Extend user info ✤ Use Roles & Capabilities to control access to features ✤ Create workflows (e.g., EditFlow plugin) ✤ Alternative login systems (LDAP, SSO)
  • 25.
    Plugins ✤ Plugins can do... practically anything: ✤ Modify posts/pages ✤ Integrate 3rd party data (Twitter, Facebook, etc.) ✤ Extend user info ✤ Use Roles & Capabilities to control access to features ✤ Create workflows (e.g., EditFlow plugin) ✤ Alternative login systems (LDAP, SSO) ✤ The sky’s the limit!
  • 26.
    Actions Actions are events Usethem to DO something, rather than to CHANGE something
  • 27.
    Actions plugins_loaded() setup_theme() wp_init() template_redirect() wp_head() wp_footer() http://andy.wordpress.com/2008/10/30/wordpress-include-stack/
  • 28.
    Filters Modify existing content <?php add_filter(‘the_content’, ‘lolify’ ); function lolify( $text_in ) { $text out = do_cool_stuff( $text_in ); return $text_out; } ?>
  • 29.
    Metadata Lets you addadditional details beyond what WordPress provides out-of-the- box.
  • 30.
    Metadata ✤ “Data about Data” Lets you provide additional details that may or may not be visible on the site.
  • 31.
    Putting it together ✤ codex.wordpress.org ✤ make.wordpress.org ✤ wpdevel.wordpress.com
  • 32.
    Who are you? DougalCampbell @dougal dougal.us / dougal.gunters.org dougal.campbell@gmail.com