GetSimple Plugin Boilerplate

I just pushed a small repository to github that provides an object-oriented approach to authoring GetSimple plugins. For its part, GetSimple is a tiny content management system that’s worth a look on any project where WordPress seems too big. Both platforms share a very similar design, and developers versed in WordPress will find many similarities (for better and for worse) in GetSimple’s own plugins.

I’ve previously offered up a minimalist boilerplate for developing WordPress plugins, and many of its features are reflected in the GetSimple analog. Besides encouraging encapsulation and minimizing repetition, the boilerplate also exposes a declarative interface for several key plugin features, including:

  • Registering actions, filters, styles, and scripts
  • Setting and managing plugin defaults and user data
  • Rendering content in MVC-style views
  • Managing routes with URL- and path-related helpers

Translated into code, a trivial plugin derived from the boilerplate’s GetSimplePlugin class might end up looking something like this:

require_once('myplugin/get_simple_plugin.php');

class MyPlugin extends GetSimplePlugin {

    protected
        $_defaults = array('foo' => 'bar'),
        $_actions = array('theme-sidebar' => 'admin_menu');

    public function __construct () {
        $this->_info = array(
            'id' =>             basename(__FILE__, '.php'),
            'name' =>           'Demo plugin',
            'version' =>        '1.0',
            'author' =>         'RJ Zaworski <rj>',
            'author_website' => 'http://rjzaworski.com/', 
            'description' =>    'Demo plugin',
            'page_type' =>      'theme',
            'menu_callback' =>  'admin_view'
        );
        parent::__construct();
    }

    public function admin_menu () {
        createSideMenu($this->_info['id'], 'Contact Link');
    }

    public function admin_view () {
        /** Implement admin view here **/
    }
}

new MyPlugin();</rj>

Source code for a demonstration plugin is available on Github.

Let’s keep in touch

Reach out on Twitter or subscribe for (very) occasional updates.

Hey, I'm RJ: digital entomologist and intermittent micropoet, writing from the beautiful Rose City.