relevanssi_bots_to_block

apply_filters( 'relevanssi_bots_to_block', array $bots )

When Relevanssi spam blocking blocks bots from search results pages, this filter hook is used to modify the bot list.

Parameters

$bots
(array) The array of bots Relevanssi should block from logging. The array key is the name of the bot and the value is the user agent string for the bot. The default value is

array(
  'Google Mediapartners' => 'Mediapartners-Google',
  'GoogleBot'            => 'Googlebot',
  'Bing'                 => 'Bingbot',
  'Yahoo'                => 'Slurp',
  'DuckDuckGo'           => 'DuckDuckBot',
  'Baidu'                => 'Baiduspider',
  'Yandex'               => 'YandexBot',
  'Sogou'                => 'Sogou',
  'Exalead'              => 'Exabot',
  'Majestic'             => 'MJ12Bot',
);

More information

Relevanssi gets the user agent of the bot from $_SERVER['HTTP_USER_AGENT'] and compares it against the values in the array filtered by this hook, and if there’s a match (using stristr(), ie. case-insensitive in-string search), the search will be immediately terminated.

To add a new bot to the list:

add_filter( 'relevanssi_bots_to_not_log', function( $bots ) {
    return array_merge( $bots, array( 'Bad Bot' => 'BadBot' ) );
}

The same bot list is used elsewhere in Relevanssi, but with different filter hooks for different contexts. If you want to modify the bot list for logging purposes, you can use the relevanssi_bots_to_not_log filter hook.