Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Source File
Located in /libs/Security.php on line 340.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_track_notable_bots"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
function track_notable_bots(){
if ( $this->is_minimal_mode() ){return null;}
$override = apply_filters('pre_track_notable_bots', null);
if ( isset($override) ){return;}
//Ignore logged-in users
if ( is_user_logged_in() ){
return null;
}
$this->timer('Notable Bot Tracking', 'start', '[Nebula] Security');
if ( isset($this->super->server['HTTP_USER_AGENT']) ){
$user_agent = str_replace(' ', '_', strtolower($this->super->server['HTTP_USER_AGENT'])); //Normalize the user agent for matching against
//Lighthouse (Ex: web.dev) (Formerly Google Page Speed Insights) - Ignore Nebula Dashboard tests (?noga)
if ( !isset($this->super->get['noga']) && str_contains($user_agent, 'chrome-lighthouse') ){
if ( $this->url_components('extension') !== 'js' ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Chrome Lighthouse')));
}
}
//W3C Validators
if ( str_contains($user_agent, 'w3c_validator') || str_contains($user_agent, 'w3c_css_validator') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'W3C Validator')));
}
//Redditbot
if ( str_contains($user_agent, 'redditbot') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Redditbot')));
}
//OpenAI GPT Bot
if ( str_contains($user_agent, 'gptbot') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'GPTBot')));
}
//Slackbot
if ( $this->is_slackbot() ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Slackbot')));
}
//Discordbot
if ( str_contains($user_agent, 'discordbot') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Discordbot')));
}
//Screaming Frog SEO Spider
if ( str_contains($user_agent, 'screaming_frog') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Screaming Frog SEO Spider')));
}
//Internet Archive Wayback Machine
if ( str_contains($user_agent, 'archive.org_bot') || str_contains($user_agent, 'wayback_save_page') ){
$this->ga_send_data($this->ga_build_event('notable_bot', array('bot' => 'Internet Archive Wayback Machine')));
}
}
//Other Notable Bots (these have been manually normalized to match above):
//bingbot
//seositecheckup
//gtmetrix
//pingdompagespeed or pingbot
//twitterbot
//semrushbot
//ahrefsbot
//facebookexternalhit
//microsoft_office
//google-structured-data-testing-tool
$this->timer('Notable Bot Tracking', 'end');
}
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
PHP
add_filter('pre_track_notable_bots', 'my_custom_track_notable_bots');
function my_custom_track_notable_bots(){
//Write your own code here
return true; //Return true to prevent the original function from running afterwords
}
You can completely disable this PHP function with a single line actions:
PHP
add_filter('pre_track_notable_bots', '__return_false');