The plugin system
This page is the reference for what ships and how the pieces fit together. You do not need any of it to use the product. It matters if you want to know what a plugin is for, or if you are writing one.
How plugins are found
Section titled “How plugins are found”Every folder under includes/ whose name starts with plugin_ is a plugin, provided it contains a PHP file named after the folder. So includes/plugin_invoice/ must contain invoice.php, and that file defines a class called module_invoice.
There is no registry and no list to maintain. Adding a folder in the right shape adds a plugin; removing the folder removes it.
Seven plugins load first, in a fixed order, because everything else depends on them: core, cache, db, debug, config, security and language. The rest load afterwards and are ordered by a position number each one declares, which is what sets the order of the menu.
What a plugin provides
Section titled “What a plugin provides”A plugin extends a shared base class and fills in the parts it needs. Nothing is compulsory except a constructor and an init() method.
| Method | When it is called |
|---|---|
__construct() | At load. Sets the plugin name, its menu position and its version number. |
init() | On every request, after all plugins have been constructed. This is where menus are declared, hooks are registered and stylesheets and scripts are added. |
get_install_sql() | When the plugin’s tables do not yet exist. Returns the SQL to create them. |
get_upgrade_sql() | When the installed version is older than the version in the files. Returns the SQL to bring the schema up to date. |
process() | When a form on one of the plugin’s pages is submitted. |
handle_hook() | Whenever any part of the system raises a hook. See below. |
run_cron() | Each time the scheduled task runs. |
external_hook() | For requests that have to work without a login — a payment gateway calling back, or a customer opening an emailed link. |
can_i() | Permission check for this plugin’s features. |
autocomplete() | Supplies results to the search box at the top of the admin area. |
How plugins talk to each other
Section titled “How plugins talk to each other”Plugins never call each other directly. They use hooks, and there are two kinds.
Broadcast hooks
Section titled “Broadcast hooks”Something raises a named hook, every plugin that implements handle_hook() is asked about it, and the answers are collected into an array. This is how open-ended questions are asked — for example, when an invoice needs to know which payment methods exist, it raises get_payment_methods and each payment plugin that is configured answers.
Other examples: invoice_paid fires when an invoice is settled, so other areas can react; ticket_sidebar lets any plugin add a panel to the ticket screen.
Registered callbacks
Section titled “Registered callbacks”A plugin can register a specific function against a named hook during init(), and it is called when that hook fires. This is used for the points in page rendering where plugins add content — the top of the page, the end of the menu, the foot of the content area.
The practical difference: broadcast hooks ask everybody, registered callbacks only call the plugins that asked to be called. Broadcast is simpler; registered is cheaper and more precise.
Database tables
Section titled “Database tables”A plugin that stores data returns the SQL to create its tables from get_install_sql(). The installer runs that the first time, records the plugin’s version number, and from then on compares that recorded number against the version in the files. When the files are newer, get_upgrade_sql() is asked for the statements to close the gap, they are run, and the recorded version moves forward.
This is what Settings → Upgrade → Run Manual Upgrades does, one plugin at a time. It is safe to run repeatedly: a plugin already at the current version does nothing.
Of the 66 plugins that ship, 41 own tables. The rest are behaviour only — the payment methods mostly store their settings in the shared configuration table rather than a table of their own.
Switching a plugin off
Section titled “Switching a plugin off”A plugin can be disabled by setting a configuration value named plugin_enabled_ followed by its name to 0 in the config database table.
Disabling a plugin stops it setting itself up on each request, which removes its menu entries, its hooks and its stylesheets. It does not remove it from the system entirely: its scheduled work still runs and it still answers broadcast hooks. It is a way to hide a feature, not to uninstall one. Its tables and data are left alone, so switching it back on restores everything.
Everything that ships
Section titled “Everything that ships”Sixty six plugins, with the version of each in this release.
Core and infrastructure
Section titled “Core and infrastructure”| Plugin | Version | What it does |
|---|---|---|
core | 2.154 | Shared behaviour the rest of the system builds on. |
db | 2.140 | The database layer. |
config | 2.435 | Stored settings, the Settings screens, and the upgrade process. |
security | 2.527 | Login, roles, permissions and HTML sanitising. |
session | 2.168 | Login sessions, in files or in the database. |
form | 2.277 | Form rendering and the security token that protects form submissions. |
cache | 2.232 | Caching. |
language | 2.181 | Translation of the interface. |
setup | 2.324 | The installation wizard. |
debug | 2.121 | The timing and query panel shown in debug mode. |
log | 2.1 | Activity logging. |
hook | 2.1 | A placeholder. It does nothing in this release. |
api | 2.1 | A minimal external access point. |
encrypt | 2.270 | Public key encryption used for sensitive stored values. |
captcha | 2.24 | Bot protection on public forms. |
backup | 2.117 | Database and file backups. |
help | 2.13 | In-application help links. |
Customers and people
Section titled “Customers and people”| Plugin | Version | What it does |
|---|---|---|
customer | 2.490 | Customers, customer types such as leads and suppliers, and the customer portal. |
user | 2.289 | Staff and contact accounts. |
address | 2.226 | Addresses attached to customers and invoices. |
member | 2.185 | Membership records. |
vendor | 2.122 | Suppliers you buy from. |
group | 2.198 | Grouping records for filtering and bulk actions. |
company | 2.143 | Running more than one business from one installation. |
Sales and money
Section titled “Sales and money”| Plugin | Version | What it does |
|---|---|---|
invoice | 2.809 | Invoices, credit notes, tax, currencies and payments. The largest plugin in the system. |
quote | 2.179 | Quotes, including customer approval. |
contract | 2.11 | Contracts, built on the same machinery as quotes. |
subscription | 2.204 | Repeating billing. |
product | 2.168 | Your product and service list, and categories for it. |
finance | 2.311 | Income and expense transactions and summary reporting. |
statistic | 2.167 | Dashboard figures and charts. |
signature | 2.21 | Drawn signatures for approving quotes and contracts. |
Payment methods
Section titled “Payment methods”| Plugin | Version | What it does |
|---|---|---|
paymethod_stripe | 2.245 | Card payments through Stripe. |
paymethod_paypal | 2.261 | PayPal. |
paymethod_square | 2.1 | Card payments through Square. |
paymethod_banktransfer | 2.241 | Offline bank transfer instructions. |
paymethod_check | 2.11 | Offline cheque instructions. Shown in the interface as Check. |
paymethod_other | 2.12 | Any other offline arrangement, with wording of your own. |
paymethod_coinbase, paymethod_multisafepay, paymethod_paynl | 2.11, 2.222, 2.2 | Also retired. The code remains so that historical payments still render correctly; none of the three can take a new payment. |
Work and communication
Section titled “Work and communication”| Plugin | Version | What it does |
|---|---|---|
job | 2.616 | Jobs and the tasks inside them. |
job_discussion | 2.153 | A comment thread per job. |
change_request | 2.298 | Requests to change the scope of a job. |
timer | 2.141 | Time tracking against jobs and tasks. |
ticket | 2.504 | Support tickets, including collecting replies from a mailbox. |
email | 2.365 | Sending mail, and the sent mail record. |
newsletter | 2.469 | Bulk email with its own subscriber lists. |
template | 2.260 | The editable wording of every email and document. |
note | 2.278 | Notes attached to any record. |
calendar | 2.238 | A calendar view, with feeds other calendar software can subscribe to. |
faq | 2.150 | A question and answer library. |
pin | 2.12 | Pinning records for quick access. |
dashboard | 2.142 | The home screen and its panels. |
Data, files and presentation
Section titled “Data, files and presentation”| Plugin | Version | What it does |
|---|---|---|
file | 2.574 | File uploads attached to records. |
data | 2.185 | A general purpose structured data store for things the product does not model directly. |
extra | 2.265 | Custom fields on the built-in record types. |
import_export | 2.242 | Bulk import and export. |
pdf | 2.135 | PDF generation for invoices, quotes and statements. |
table_sort | 2.228 | Sorting, filtering and paging on list screens. |
map | 2.21 | Showing an address on a map. |
website | 2.271 | Website records against a customer. |
theme | 2.407 | Theme selection, custom CSS and the asset pipeline. |
theme_adminlte | 2.159 | The AdminLTE theme. |
theme_blocks | 2.129 | The Blocks theme. |
Writing your own
Section titled “Writing your own”The smallest working plugin is a folder, a file and a class:
includes/plugin_example/example.php<?php
class module_example extends module_base {
public function __construct() { $this->module_name = 'example'; $this->module_position = 600; $this->version = 1.0; }
public static function get_class() { return __CLASS__; }
public function init() { $this->links = array( 'example_list' => array( 'name' => 'Example', 'page' => 'example_list', 'menu' => true, ), ); }}Pages live in includes/plugin_example/pages/, named after the page key — so the above looks for pages/example_list.php. Add a get_install_sql() if you need tables, and run Settings → Upgrade → Run Manual Upgrades to create them.