Making an Extension

The Runway framework supports extensions that can provide themes with additional functionality, similar to the way plugins work with WordPress.

File and Folder Structure

Extensions are stored as folders in the runway-framework/extensions directory, and for each extension there are some required files in the root of the extension folder:

admin.php

The default admin file used as the basis for the admin interface.

load.php

The main file used to register the extension. This file must have the information header for it to be recognized by Runway. It can also contains basic settings to integrate the extension with the Runway core. The name of this file can be anything you like as long as it has the information header.

object.php

The default file for the main extension class. This class should extend the basic Runway_Object class, and its object is available in any part the framework, front-end and back-end.

settings-object.php

The file used to store the admin class for the extension. This extends the core class Runway_Admin_Object; this extension class is available only in the back-end.

Information Header

An extension’s load.php file should begin with an information header section that contains some details about the extension:

<?php
/*
  Extension Name:
  Extension URI:
  Version:
  Description:
  Author:
  Author URI:
  Text Domain:
  Domain Path:
  Network:
  Site Wide Only:
*/

This information header mirrors for Runway extensions the same information header that is provided for standard WordPress plugins. Click here for more information about WordPress plugin headers. The minimum information Runway needs to recognise your extension is the Extension Name line.

In addition to the required files there is a particular folder structure that must be followed and which may be used to store particuar types of support files:

  • css – Store all stylesheets necessary for the extension in this folder.
  • images – Store all graphics used by the extension in this folder.
  • js – Store all JavaScript files used by the extension in this folder.
  • views – Store all templates used by the extension’s admin interface in this folder.

Feel free to add custom folders to this structure; for example you might add a folder named ‘inc’ to store additional PHP files required by the extension.

Create a Note

Google+