Created
October 19, 2021 08:40
-
-
Save paulgoodchild/9e996ec9b42301b768496d13a1253d55 to your computer and use it in GitHub Desktop.
Prevent running of NotBot JS based on other factors on site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare( strict_types=1 ); | |
/** | |
* Use this filter to tell Shield to NOT run the NotBot JS system. | |
* | |
* If you disable the NotBot JS system then you will likely lock-out visitors. | |
* | |
* Use of this filter is at your own risk. | |
*/ | |
add_filter( 'shield/can_run_antibot', function ( $canRun ) { | |
// $canRun defaults to true. | |
// You can change this to false based on particular settings on your site. | |
// For example, since NotBot uses a cookie, you could say that if a particular | |
// consent cookie isn't set, disable the NotBot JS. | |
if ( empty( $_COOKIE[ 'cookie_consent_set' ] ) ) { | |
$canRun = false; | |
} | |
// ALWAYS return $canRun. | |
return $canRun; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment