Hooks
modal_kit_backdrop_request
action
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.
Runs on template_redirect (priority 0) for the homepage request the modal editor makes for Site preview, after Modal Kit has checked its nonce and the user’s capability (modal_kit_backdrop_capability: Editors and Administrators by default).
By then the request is marked not to be cached (DONOTCACHEPAGE and no-cache headers) and sends X-Robots-Tag: noindex, nofollow. It prints no modals or admin bar, and its scripts are removed from the HTML, so the action is for what runs on the server: page view counters, logs and the like.
Parameters
This hook passes no arguments.
Examples
Skip your own page view counter
add_action( 'modal_kit_backdrop_request', function () {
remove_action( 'shutdown', 'my_record_page_view' );
} );
Ask later in the request
Code that runs after template_redirect can check whether the action fired.
function my_is_modal_backdrop() {
return (bool) did_action( 'modal_kit_backdrop_request' );
}
add_action( 'wp_footer', function () {
if ( my_is_modal_backdrop() ) {
return;
}
my_log_visit( get_queried_object_id() );
} );
Good to know
It doesn’t fire for visitors, or for users without the capability, even when the URL has modal_kit_backdrop=1.
The action passes no arguments.
Fired in modal-kit/includes/Backdrop.php.
Related