Developers
Built from WordPress, not around it.
A modal is one block holding core blocks, shown with the browser’s own dialog and run by the Interactivity API that ships with WordPress. Everything else is hooks, events and post meta you already know how to work with.
1
Custom block in free
modal-kit/modal. Everything inside it is a core block.
37
PHP hooks
Filters and actions in Free and Pro, listed below.
10
Editor filters
For the editor and settings screens, through wp.hooks.
0
jQuery or UI libraries
The browser’s dialog, the Interactivity API and script modules.
Architecture
One block, the platform for the rest
One block, core blocks inside
The free plugin registers a single block, modal-kit/modal. Headings, images, buttons, columns and video are the core blocks you already use, so themes style them as usual.
The browser’s own dialog
Each modal renders as a <dialog>. The browser puts it above the page and makes the page behind inert. Focus moves to the heading on open and back to the trigger on close.
Interactivity API and script modules
The front end is a viewScriptModule on the Interactivity API that ships with WordPress. Triggers and the video player are separate modules, imported only when a modal on the page uses them.
Editor matches the front end
One shared style.scss styles both the editor canvas and your site. editor.scss is editor chrome only.
Your theme’s values
Native, Soft and Editorial read theme.json presets for colour, spacing, radius and type, never hard-coded colours. Fixed styles are token sets you can add with modal_kit_styles.
Validated settings
Triggers, rules, overrides and plugin settings are checked against JSON schemas on save, in the REST API as in the editor.
Pro’s blocks
Each one goes inside a modal and loads its script only where it’s used.
modal-kit/step
modal-kit/form
modal-kit/field
modal-kit/prize-wheel
modal-kit/scratch-card
modal-kit/pick-a-gift
modal-kit/slot-reel
modal-kit/age-check
modal-kit/countdown
modal-kit/carousel
modal-kit/slide
modal-kit/reviews
modal-kit/cart-summary
PHP hooks
Every filter and action
This list comes from the plugins’ source, with the arguments each hook passes. Pro uses the same hooks to extend the free plugin. Each hook has its own page with working code: open its name.
Hook
What it’s for
filter
Add or change layouts. A layout can extend a built-in one (base) and turn off closing (closable: false). Pro adds the age gate this way.
$layouts
filter
Add fixed styles: a token set of colours, fonts, radius and shadow, like the bundled Fieldnote. Fonts beyond the bundled ones are yours to load.
$styles
filter
Change the values Native, Soft and Editorial take from theme.json: surface, ink, radius, space, shadow, primary and on-primary, and z, the stacking order from Settings → Display.
$tokens
filter
Extend the JSON schema for a modal’s triggers, rules, overrides or enabled meta, for example to allow a new trigger type.
$schema, $key
filter
Decide whether a modal’s page targeting matches the page being built.
$targeted, $post
filter
Change the triggers, rules, closing and focus settings the browser receives for a modal.
$context, $post, $resolved
filter
Add markup to a modal’s panel before the dialog is built. Pro adds step progress here.
$panel, $post, $resolved, $attrs
filter
Register button actions the front end understands. Pro adds its step, form, game and cart actions.
$actions
Add attributes to a button that uses your action. The WP_HTML_Tag_Processor is positioned on the button.
$processor, $action, $block
filter
Change the prefix of modal links and dialog ids. The default, modal-, is set in Settings → General.
$prefix
filter
Change the close button’s accessible label for a modal.
$label, $post_id
Change the capabilities needed to create, edit and publish modals.
$caps
filter
Change the categories in the template picker.
$categories
Add template collections to the picker.
$collections
Set the types listed inside each collection.
$types
filter
Change the triggers, rules and overrides a starter template applies when it’s picked.
$settings
Change who gets the editor’s homepage backdrop. Default: edit_others_posts.
$capability
action
Fires when the editor loads your homepage as its backdrop, so server-side analytics can skip that visit.
filter
Folders that speed and cache plugins must not combine, delay or move to a CDN. Add yours if your add-on has its own script modules. Pro adds its folder.
$paths
filter
The Pro features listed in the free plugin’s screens. Pro removes the ones it provides.
$listings
Hook
What it’s for
filter
Add form destinations to Send to. See Your own form destination below.
$list
Add or remove bot check providers.
$list
Hostnames a bot check token may be solved on, such as a static copy of the site that still posts to this one.
$hosts
filter
Supply the visitor’s two-letter country from your own lookup, or an empty string when unknown. Never store the visitor’s address.
$code, $lookup
Add country lookups: a label, the server keys to read and the header they come from.
$sources
filter
Set a modal’s main goal on Results: played, signed_up, coupon, watched, clicked or added_to_cart.
$goal, $post
filter
Whether a page sends counts to your site. Simply Static exports are handled; turn it off for other static exporters.
$counts
action
Fires after a game creates a WooCommerce coupon, for example to log it or send it to a CRM.
$code, $prize, $modal_id
The address used for rate limits and one play per visitor, for proxy setups. The constant MODAL_KIT_PRO_CLIENT_IP_HEADER covers the usual case.
$address
Plays one address gets per hour. 20 by default.
$limit
Entries a form takes per day through your site. 1,000 by default.
$limit, $modal_id, $form_id
Times one email address can be sent per day, across forms. 3 by default.
$limit
Results requests one address can send in ten minutes. 120 by default.
$limit
Events one modal can count per hour. 20,000 by default.
$limit, $modal_id
Hook
What it’s for
filter
Whether the site is staging or local, where the license key is checked without using one of its sites.
$staging
filter
Short-circuit a rollback, for hosts that manage plugin files themselves. Return true or a WP_Error to skip it.
$result, $package, $version
filter
The free plugin version Pro was tested up to, used to warn about a newer free plugin.
$tested
Editor filters (JavaScript)
Through wp.hooks, for adding to the editor and settings screens.
The editor side of modal_kit_layouts, with labels, position labels, mobile help and a note for the Triggers panel.
layouts
Trigger types in the Triggers panel: label, description, defaults, and optionally a Settings component and a menu group.
types
Extra groups in the add-trigger menu.
[]
Actions in a button’s Modal Kit action menu: { value, label, Settings? }.
actions
Editor chrome around the modal on the canvas. Pro adds step tabs.
null, { clientId, attributes, setAttributes }
Tabs on Modal Kit → Settings: { name, title, Component, saves }.
tabs
Extra rows on the Tools tab.
[]
Whether the template picker shows live previews.
false
What the block’s Style panel edits. Pro points it at the A/B variant on the canvas.
useOwnStyle
The editor that opens from Edit on Settings → Styles. Pro adds its style editor.
null
In the browser
Links, events and your own scripts
Each modal is a <dialog> with the id modal-{slug}. Any link to #modal-{slug} or ?modal={slug} opens it, even without JavaScript for the hash link. Both formats and the prefix are in Settings → General.
Event
Fires on
When, and its detail
modal-kit:ready
Free
dialog
The modal is set up and listens for modal-kit:request-open. Its dialog also gets data-modal-kit-ready.
{ slug }
modal-kit:configure
Free
dialog
Just before a modal starts its automatic triggers; change detail.config to adjust them (Pro swaps in an A/B variant’s trigger). To set a modal up first, put data-modal-kit-wait on the dialog or an element inside it and remove it when done: the triggers wait for it, at most 4 seconds.
{ slug, config }
modal-kit:open
Free
dialog
A modal opened. source is link, a trigger type such as scroll, or what an add-on passed.
{ slug, source }
modal-kit:close
Free
dialog
A modal closed. reason is button, esc, outside, action, auto (the auto-close timer), ended (its video ended) or closed.
{ slug, reason }
modal-kit:action
Free
button
A button with an add-on’s action was pressed (registered with modal_kit_button_actions).
{ action, button }
modal-kit:video-ended
Free
dialog
The video in a modal finished.
modal-kit:form-submitted
Pro
form
A Form block’s entry was sent.
modal-kit:game-played
Pro
game
A wheel was spun, a card scratched, a gift picked or a reel pulled.
{ modal, game, prize, prizeId }
modal-kit:prize-won
Pro
game
The play won a prize. The detail has the prize’s label, never its code.
{ modal, game, prize, prizeId }
modal-kit:added-to-cart
Pro
dialog
A product was added to the cart from the modal (counted as the Added to cart goal).
modal-kit:age-passed
Pro
dialog
A visitor passed the age gate.
modal-kit:event
Pro
window
Every analytics event, when Browser event is on in Settings → Results: modal_shown, modal_closed, modal_converted, game_played and prize_won. In an A/B test the props include variant (a–d).
{ name, modal, goal?, game?, prize? }
Opening a modal from your code
Set location.hash to #modal-{slug}. That counts as a link, so frequency and other rules don’t hold it back.
Or dispatch modal-kit:request-open on the dialog once it has data-modal-kit-ready (or after modal-kit:ready). The modal’s rules still apply unless you pass source: ‘link’.
Close it with a button set to the Close modal action, or let visitors use Esc and the close button. Focus returns to whatever opened it when you pass trigger.
const dialog = document.getElementById( 'modal-newsletter' );
dialog.addEventListener( 'modal-kit:close', ( event ) => {
console.log( event.detail.slug, event.detail.reason );
} );
// Open it from your own script. Rules still apply.
dialog.dispatchEvent(
new CustomEvent( 'modal-kit:request-open', {
detail: { source: 'my-script', trigger: myButton },
} )
);
// With Browser event on (Settings → Results).
window.addEventListener( 'modal-kit:event', ( event ) => {
const { name, modal, ...props } = event.detail;
} );
REST API and WP-CLI
Modals are posts
A modal is a post of type mk_modal, so the core REST API and WP-CLI already work with it. Its settings are post meta registered with a JSON schema, so WordPress rejects anything that doesn’t fit.
/wp/v2/mk_modal
Users who can edit modals
The core posts endpoint for modals: title, content and meta. The meta keys are _modal_kit_enabled, _modal_kit_triggers, _modal_kit_rules and _modal_kit_overrides.
GET /modal-kit/v1/export
Administrators
Every modal with its triggers, rules and overrides, and the plugin settings unless you pass settings=false. The same file as Settings → Tools.
POST /modal-kit/v1/import
Administrators
Imports that file: { data }, with replace: true to overwrite modals that have the same slug.
wp post list --post_type=mk_modal
WP-CLI
There are no custom WP-CLI commands. Core post and post meta commands work on modals as on any post type.
curl -X POST https://example.com/wp-json/wp/v2/mk_modal/42 \
-u "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \
-H "Content-Type: application/json" \
-d '{ "meta": { "_modal_kit_triggers": [
{ "type": "scroll", "percent": 50 }
] } }'
The other routes under modal-kit/v1 and modal-kit-pro/v1 serve the plugins’ own screens and front end. They can change between versions, so build on the ones above.
Forms · Pro
Your own form destination
Add a class to modal_kit_pro_providers and it appears under Send to in the Form block. A provider either gives the browser a public address to post to, or sets the transport to relay and sends from your site, so any secret stays on the server.
add_filter( 'modal_kit_pro_providers', function ( $providers ) {
$providers[] = new class() extends \ModalKit\Pro\Providers\Provider {
public function id() {
return 'acme-crm';
}
public function label() {
return __( 'Acme CRM', 'my-plugin' );
}
// Asks for an API key on Settings → Integrations.
public function needs_key() {
return true;
}
// Sent from the site, so it needs live WordPress.
public function needs_live_site() {
return true;
}
// What the page may see: no address, so the
// browser hands the entry to your site.
public function public_config( $form ) {
return array(
'url' => '',
'transport' => 'relay',
'email' => 'email',
);
}
// $fields are keyed by each Field block's name.
public function send( $form, $fields, $tags ) {
$result = $this->api_json(
'POST',
'https://api.acme.example/v1/contacts',
array( 'Authorization' => 'Bearer ' . $this->key() ),
array(
'email' => $fields['email'] ?? '',
'name' => $fields['name'] ?? '',
'tags' => $tags,
)
);
if ( is_wp_error( $result ) ) {
return $result;
}
if ( $result['code'] < 200 || $result['code'] >= 300 ) {
return self::rejected( $result );
}
return true;
}
};
return $providers;
} );
{
"modal": "welcome-offer",
"fields": {
"email": "[email protected]",
"name": "Sam"
},
"tags": [ "welcome" ],
"sentAt": "2026-10-26T10:31:00+00:00",
"site": "https://example.com/"
}
Return true or a WP_Error from send(). Failures show in Submissions with the error, and the visitor sees the form’s “couldn’t send” message.
For a service with a public, cross-origin endpoint, return its address with transport post instead, and the browser posts straight to it, also on a static export.
Webhooks post the body above. modal is the modal’s slug and fields are keyed by each Field block’s name.