Addofy for developers
Addofy is built to be extended. Wherever it shows, collects or decides something, your plugin or theme can add, change or remove it through a filter or an action, without touching Addofy's code and without DOM tricks. This documentation covers that public API: PHP hooks, PHP classes, the JavaScript API, events, JS filters and CSS tokens.
Where to start
- Quick start: your first extension: a small plugin with a module and a notice.
- Writing a module: the main building block.
- The JavaScript API: commands, shortcuts, events and filters.
- Hook reference: every public action and filter.
Ground rules
- Native first. Where WordPress or WooCommerce already has a hook (
admin_bar_menu,add_meta_box,manage_{screen_id}_columns,register_rest_route,WP_CLI::add_command()), Addofy supports that hook and you should use it. Addofy adds its ownadba_hooks only for the parts it builds itself. - Default equals no change. Every filter starts with the current value. Without callbacks Addofy behaves exactly as without the hook.
- Validated. Addofy checks what a filter returns (type, required keys, allowed values). A wrong result falls back to the default and, with
WP_DEBUGon, writes one log line naming the hook. A broken callback never breaks a screen. - Capabilities stay native. A filter can hide or reorder, never grant access. Tabs, cards and actions you add check their own capability.
- Addofy's own settings stay reachable. Its menu, its settings tabs and its settings templates cannot be hidden or removed through any hook.
- Same loading rules for you. Assets you queue through Addofy load only where Addofy is active: never on the frontend, never in safe mode (
?adba_safe=1,ADBA_SAFE_MODE) and never on an excluded screen.
Why the prefix is `adba`
Everything public in the code carries the prefix adba: PHP functions and hooks (adba(), adba_register_module(), adba_* filters and actions), constants (ADBA_SAFE_MODE), script handles (adba-core), the window.adba object and the CSS tokens (--adba-*). The prefix dates from the plugin's working name, before it was called Addofy. It stays: renaming it would break every plugin, theme and snippet that already uses these hooks, and adba is short and unique, so it does not clash with other plugins. The name in the interface and in these docs is Addofy; the prefix in the code is adba, and that will not change.
Stability promise
Everything marked @api in a docblock is public: every hook in the hook reference, the classes and methods listed below and the window.adba API in docs/adba.d.ts. Each carries @since with the version it arrived in. A public hook or method is only renamed or removed through apply_filters_deprecated() / do_action_deprecated() (or a JS console warning), with at least one minor version of overlap. Classes and methods without @api are internal and may change in any release.
Public PHP classes and helpers:
| Name | Use |
|---|---|
adba( ?string $service ) | The service container, or one service: adba( 'assets' ), adba( 'rules' ), adba( 'store' ), adba( 'config' ). |
adba_register_module( string $class ) | Registers a module class. Call it before plugins_loaded priority 20. |
adba_is_active_on_screen( ?string $screen_id ) | Whether Addofy is active on the (current) screen. |
adba_trigger_alert( string $event, int $object_id, array $data ) | Sends a notification event (see adba_alert_events). An event can bring default_roles (since 2.36.0): on for those roles until the owner or the user chooses. |
adba_alerts_browser( int $user_id = 0 ) | Since 2.36.0. Whether Addofy sends browser notifications to the user: the notifications module is on and the user switched them on in the profile. Leave out your own browser notification when it is true. |
adba_is_order_blocked( int $user_id = 0, string $email = '' ) | Since 2.36.0. Whether the customer may not place new orders (module Block customers, after the adba_order_block_is_blocked filter). False when the module is off and in Light. |
adba_remove_alerts( string $event, int|int[] $object_ids ) | Since 2.36.0. Removes the notifications of an event for those objects, for every user (also archived ones). Call it when the object is gone, so no notification points at nothing. An open list loads again. |
Filter adba_alert_sections | Since 2.36.0. Adds a section (heading) to the notification list: id => array( 'label' => ..., 'order' => ... ). Put an event in it with 'section' => id in adba_alert_events. The site owner and each user can hide a section; its notifications then show under General. |
Modules\ModuleInterface, Modules\AbstractModule | A module. |
Modules\Settings\TabInterface, Modules\Settings\AbstractTab | A settings tab. |
Settings\Fields\FieldInterface, Settings\Fields\AbstractField | A settings field type. |
Compat\AdapterInterface, Compat\AbstractAdapter | A compatibility adapter. |
Visibility\Collectors\CollectorInterface, Visibility\Collectors\AbstractCollector | A collector for the Visibility tab. |
Visibility\RuleEngine::is_hidden() | Whether an item is hidden for the current user. |
Modules\Search\SearchProviderInterface, FilterableSearchProviderInterface | A server-side search provider. |
Modules\OrderActions\QuickActionInterface | A section in the order quick actions popup. |
Setup\StepInterface, Setup\AbstractStep | A quick start step. |
Core\Assets::enqueue_external() | Queue your own script or stylesheet. |
Settings\Prefs (container service prefs): effective(), stored(), defaults(), update(), extension_defs() | Read and change user preferences, yours included. Store::extension_prefs() still works but is deprecated; Store::all_prefs() was removed in 2.34.0. |
Support\Filter | Validated filters, for your own hooks too. |
Support\Components::card(), toggle() | Markup in the Addofy style. |
Support\View | Renders Addofy templates (with theme overrides). |