Skip to content
Ultimate Client Manager

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.

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.

A plugin extends a shared base class and fills in the parts it needs. Nothing is compulsory except a constructor and an init() method.

MethodWhen 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.

Plugins never call each other directly. They use hooks, and there are two kinds.

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.

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.

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.

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.

Sixty six plugins, with the version of each in this release.

PluginVersionWhat it does
core2.154Shared behaviour the rest of the system builds on.
db2.140The database layer.
config2.435Stored settings, the Settings screens, and the upgrade process.
security2.527Login, roles, permissions and HTML sanitising.
session2.168Login sessions, in files or in the database.
form2.277Form rendering and the security token that protects form submissions.
cache2.232Caching.
language2.181Translation of the interface.
setup2.324The installation wizard.
debug2.121The timing and query panel shown in debug mode.
log2.1Activity logging.
hook2.1A placeholder. It does nothing in this release.
api2.1A minimal external access point.
encrypt2.270Public key encryption used for sensitive stored values.
captcha2.24Bot protection on public forms.
backup2.117Database and file backups.
help2.13In-application help links.
PluginVersionWhat it does
customer2.490Customers, customer types such as leads and suppliers, and the customer portal.
user2.289Staff and contact accounts.
address2.226Addresses attached to customers and invoices.
member2.185Membership records.
vendor2.122Suppliers you buy from.
group2.198Grouping records for filtering and bulk actions.
company2.143Running more than one business from one installation.
PluginVersionWhat it does
invoice2.809Invoices, credit notes, tax, currencies and payments. The largest plugin in the system.
quote2.179Quotes, including customer approval.
contract2.11Contracts, built on the same machinery as quotes.
subscription2.204Repeating billing.
product2.168Your product and service list, and categories for it.
finance2.311Income and expense transactions and summary reporting.
statistic2.167Dashboard figures and charts.
signature2.21Drawn signatures for approving quotes and contracts.
PluginVersionWhat it does
paymethod_stripe2.245Card payments through Stripe.
paymethod_paypal2.261PayPal.
paymethod_square2.1Card payments through Square.
paymethod_banktransfer2.241Offline bank transfer instructions.
paymethod_check2.11Offline cheque instructions. Shown in the interface as Check.
paymethod_other2.12Any other offline arrangement, with wording of your own.
paymethod_coinbase, paymethod_multisafepay, paymethod_paynl2.11, 2.222, 2.2Also retired. The code remains so that historical payments still render correctly; none of the three can take a new payment.
PluginVersionWhat it does
job2.616Jobs and the tasks inside them.
job_discussion2.153A comment thread per job.
change_request2.298Requests to change the scope of a job.
timer2.141Time tracking against jobs and tasks.
ticket2.504Support tickets, including collecting replies from a mailbox.
email2.365Sending mail, and the sent mail record.
newsletter2.469Bulk email with its own subscriber lists.
template2.260The editable wording of every email and document.
note2.278Notes attached to any record.
calendar2.238A calendar view, with feeds other calendar software can subscribe to.
faq2.150A question and answer library.
pin2.12Pinning records for quick access.
dashboard2.142The home screen and its panels.
PluginVersionWhat it does
file2.574File uploads attached to records.
data2.185A general purpose structured data store for things the product does not model directly.
extra2.265Custom fields on the built-in record types.
import_export2.242Bulk import and export.
pdf2.135PDF generation for invoices, quotes and statements.
table_sort2.228Sorting, filtering and paging on list screens.
map2.21Showing an address on a map.
website2.271Website records against a customer.
theme2.407Theme selection, custom CSS and the asset pipeline.
theme_adminlte2.159The AdminLTE theme.
theme_blocks2.129The Blocks theme.

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.