Ben Doherty: OOP for Theme Development

3 responses on “Ben Doherty: OOP for Theme Development

  1. Robert O'Rourke

    Often overlooked regarding anonymous functions. You can pass in variables from the outside scope quite easily with ‘use()’:

    $var = 'some string';
    add_filter( 'some_filter', function( $value ) use( $var ) {
         return $value . $var;
    }, 10, 1 );



    Robert, you are right that anonymous functions are very useful, especially when defining short filter or action handlers that use variables in the current scope (closures.)

    In this talk, I tried to avoid using PHP features that are newer than the minimum version of PHP required by WordPress, which is 5.2.4. Since closures / anonymous functions are a PHP 5.3-ism, I didn’t want to encourage their usage and then have developers mystified at why their code breaks on a host that only supports PHP 5.2.

    Thanks for your input!


  3. Nicolas

    Hi Ben,

    Your presentation made me change the way I used to code WordPress Theme.
    My theme (Customizr) is built upon the OOP principles you describes.

    Thanks for those awesome slides!
    PS : I credit you in my functions.php file


Continue the discussion

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


June 13, 2013

This presentation covers techniques and coding standards for developing concise, high-quality, re-usable theme functionality using Object Oriented Programming methodology. Learn how to employ the WordPress actions and filters API to create communication channels between objects without creating fragile object dependencies. Topics covered include encapsulation, re-usability, singletons and best practices. Naming conventions for symbols and files will be covered and explained.

Presentation Slides »

Rate this:


WordCamp Providence 2012 15


Ben Doherty 1


Theme Development 96


English 9697

MP4: Low, Med, High, Original
OGG: Low
Subtitle this video →
%d bloggers like this: