Hooks
Docs Developers
Hooks and filters.
Every filter and action in Modal Kit and Modal Kit Pro, and the JavaScript filters for the editor and settings screens. Each page has the hook’s arguments, what it returns and code you can paste into your own plugin.
For the architecture, the browser events, the REST routes and opening a modal from your own script, see the Developers page.
Where the code goes
PHP hooks: a small plugin of your own
Put PHP snippets in your own plugin or a must‑use plugin, not in Modal Kit’s files, so updates don’t remove them. A file in wp-content/mu-plugins/ loads on every request with nothing to activate. Add a hook before WordPress fires init, as plugins usually do: some of Modal Kit’s values are read early in init, and each page says when that matters.
<?php
/**
* Plugin Name: My Modal Kit tweaks
*/
defined( 'ABSPATH' ) || exit;
add_filter( 'modal_kit_close_label', function ( $label, $post_id ) {
return __( 'Close this offer', 'my-plugin' );
}, 10, 2 );
Editor filters: a script on the right screen
The editor filters run in the browser, through wp.hooks. Build your script with @wordpress/scripts and load it on the screen that applies the filter, before that screen’s app starts. For the modal editor, enqueue on enqueue_block_editor_assets for the mk_modal post type and depend on modal-kit-editor. For Modal Kit → Settings, enqueue on admin_enqueue_scripts when the hook suffix is mk_modal_page_modal-kit-settings and depend on modal-kit-settings. Each filter’s page names its screen.
add_action( 'enqueue_block_editor_assets', function () {
$screen = get_current_screen();
if ( ! $screen || 'mk_modal' !== $screen->post_type ) {
return;
}
$asset = require __DIR__ . '/build/editor.asset.php';
wp_enqueue_script(
'my-plugin-modal-editor',
plugins_url( 'build/editor.js', __FILE__ ),
array_merge( $asset['dependencies'], array( 'modal-kit-editor' ) ),
$asset['version'],
true
);
}, 20 );
add_action( 'admin_enqueue_scripts', function ( $hook_suffix ) {
if ( 'mk_modal_page_modal-kit-settings' !== $hook_suffix ) {
return;
}
$asset = require __DIR__ . '/build/settings.asset.php';
wp_enqueue_script(
'my-plugin-modal-settings',
plugins_url( 'build/settings.js', __FILE__ ),
array_merge( $asset['dependencies'], array( 'modal-kit-settings' ) ),
$asset['version'],
true
);
}, 20 );
Every hook
Free · PHP hooks
Add a layout for the Modal block, or change a built-in one. Pro adds its age gate this way.
filter
Free
PHP
Add fixed styles: token sets of colours, fonts, radius and shadow that look the same on any theme, like the bundled Fieldnote, Harbor and Night.
filter
Free
PHP
Change the values Native, Soft and Editorial take from the theme: surface, ink, radius, spacing, shadow and primary colour, plus the z-index.
filter
Free
PHP
Extend the JSON schema of a modal’s triggers, rules, overrides or on/off meta, for example to allow a new trigger type or store your own settings.
filter
Free
PHP
Decide on the server whether a modal’s page targeting matches the page being built, for conditions Show on can’t express.
filter
Free
PHP
Change what the browser receives for a modal: its triggers, display rules, closing, focus and scroll settings.
filter
Free
PHP
Change a modal’s rendered panel before the dialog is built: add markup, attributes or classes. Pro adds step progress here.
filter
Free
PHP
Register a button action the front end understands, so a core Button in a modal can run your code. Pro adds step, form, cart and game actions.
filter
Free
PHP
modal_kit_render_button_action
Add attributes to a button that uses your action, such as data for your script or a link for visitors without JavaScript.
action
Free
PHP
Change the prefix of modal anchor links and dialog ids, which Modal Kit → Settings → General sets to modal- by default.
filter
Free
PHP
Change the close button’s label for one modal or all of them: read aloud for the × button, or shown as text when the label is visible.
filter
Free
PHP
modal_kit_post_type_capabilities
Change the capabilities needed to create, edit, publish and delete modals. By default Authors and Contributors draft, and Editors publish.
filter
Free
PHP
Add, rename or remove the categories in the template picker. Starters you register in your own category show up next to Modal Kit’s.
filter
Free
PHP
Add template collections to the picker: named groups of starters listed under Collections. Pro adds Studio, Shop, Popups and more.
filter
Free
PHP
modal_kit_pattern_collection_types
Add type filters inside a template collection, such as Newsletter, Coupon or Age gate in Pro’s Popups. A starter’s type is one of its pattern categories.
filter
Free
PHP
Set the triggers, display rules and overrides a starter applies to the modal when someone picks it in the template picker.
filter
Free
PHP
Change who sees the real homepage behind the modal in the editor’s Site preview. The default, edit_others_posts, covers Editors and Administrators.
filter
Free
PHP
Fires when the editor loads your homepage as the backdrop behind a modal, so server-side analytics and counters can skip that visit.
action
Free
PHP
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.
filter
Free
PHP
The Pro features listed in the free plugin’s screens and block. Pro removes each one it provides; an add-on can hide listings by key or area.
filter
Free
PHP
Pro · PHP hooks
Add your own form destination to the Form block’s Send to list, posted from the browser or relayed through your site.
filter
Pro
PHP
modal_kit_pro_captcha_providers
Add, replace or remove the bot check services offered under Bot check on Modal Kit → Settings → Integrations.
filter
Pro
PHP
modal_kit_pro_captcha_hostnames
Accept bot check tokens solved on other hostnames, such as a static copy of the site that still sends its forms to this one.
filter
Pro
PHP
Supply the visitor’s country for Pro’s country rule from your own lookup. Return a two-letter code, or an empty string when unknown.
filter
Pro
PHP
Add, reorder or remove the request headers Pro reads the visitor’s country from for the country rule.
filter
Pro
PHP
Choose what counts as a conversion for a modal on Results: played, signed up, coupon used, watched, clicked or added to cart.
filter
Pro
PHP
Decide whether a page sends Results events to your site. Turn it off for static exporters other than Simply Static, or on staging.
filter
Pro
PHP
Fires after a game creates a unique WooCommerce coupon for a prize. Add restrictions, log it or pass it on.
action
Pro
PHP
Change the address Pro uses for rate limits and one play per visitor, for proxy setups the constant doesn’t cover.
filter
Pro
PHP
Change how many game plays one address gets per hour, across every game on the site. 20 by default.
filter
Pro
PHP
modal_kit_pro_form_daily_limit
Change how many entries one form accepts per day through your site. 1,000 by default.
filter
Pro
PHP
modal_kit_pro_address_daily_limit
Change how many times one email address can be sent per day through your site, across all forms. 3 by default.
filter
Pro
PHP
modal_kit_pro_events_rate_limit
Change how many Results requests one address can send in ten minutes. 120 by default.
filter
Pro
PHP
modal_kit_pro_modal_events_per_hour
Change how many Results events one modal can count per hour, from all visitors together. 20,000 by default.
filter
Pro
PHP
Pro · Updates
Say whether a site is staging or local. Those check the license key without using one of its sites, and still get updates.
filter
Pro
PHP
Refuse or take over a rollback from the License tab, for hosts and deployments that manage plugin files themselves.
filter
Pro
PHP
Change the Modal Kit version Pro counts as tested, which decides the compatibility note under Pro on the Plugins screen.
filter
Pro
PHP
Editor filters · JavaScript
Add layouts to the Modal block in the editor, with their labels, position names, mobile help and a note for the Triggers panel.
filter
Free
JavaScript
Add automatic trigger types to the Triggers panel’s Add trigger menu, each with a label, description, defaults and its own settings.
filter
Free
JavaScript
Add your own sections to the end of the Add trigger menu in the Triggers panel, as components that render a menu group.
filter
Free
JavaScript
Add actions to the Action panel of Button blocks inside a modal, each with its own settings.
filter
Free
JavaScript
Add editor-only controls inside the Modal block on the canvas, like Modal Kit Pro’s step tabs and A/B variant bar.
filter
Free
JavaScript
Point the Modal block’s Style panel at another block, or add a note to it, by wrapping the React hook that says what the panel edits.
filter
Free
JavaScript
Add, reorder or replace tabs on Modal Kit → Settings. Each tab is a React component, saved with Save Changes unless it opts out.
filter
Free
JavaScript
Supply the style editor on Modal Kit → Settings → Styles, the component behind New style, Edit and Edit a copy. Modal Kit Pro provides one.
filter
Free
JavaScript
Add rows to the Tools tab on Modal Kit → Settings, between Setup wizard and Uninstall.
filter
Free
JavaScript
Turn on the template picker’s live preview of the selected starter, with a Desktop / Mobile switch. Off in Free; Modal Kit Pro turns it on.
filter
Free
JavaScript