Hooks
modal_kit_pro_results_count
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.
Runs while a page with a modal is built. When it returns false, the page gets no address to send events to, so nothing from it is counted on Results. Analytics services switched on under Also send events to still get their events.
Pro’s own answer is false when Count results on this site is off on Modal Kit → Settings → Results, for previews, for administrators when Don’t count logged-in administrators is on, and for Simply Static’s export requests (?simply_static_page=).
Parameters
Parameter
Description
$counts
bool
Whether this page sends events.
Returns
bool Whether it does, cast to a boolean.
Examples
Don’t count on staging
add_filter( 'modal_kit_pro_results_count', function ( $counts ) {
return 'production' === wp_get_environment_type() ? $counts : false;
} );
Another static exporter
Your exporter sends an X-My-Export header with each page it fetches, so the exported copies send nothing.
add_filter( 'modal_kit_pro_results_count', function ( $counts ) {
return empty( $_SERVER['HTTP_X_MY_EXPORT'] ) ? $counts : false;
} );
Good to know
Returning true overrides Pro’s false for previews and administrators. It can’t switch counting on: while Count results on this site is off, the site refuses events.
Applied in modal-kit-pro/includes/Results.php.