Condition for filtering bots | WordPress.org

[ad_1]

Hello, thanks for supporting a great plugin!

Due to the big problem of the influx of bots, is it possible to create a condition in the plugin?
The cache works for “good” bots and disables the cache for visits with an empty referrer.

	$userAgent = $_SERVER['HTTP_USER_AGENT'];

$down_reg = mb_strtolower($_SERVER['HTTP_USER_AGENT']);
        $down_reg = str_replace(array(' '), '', $down_reg);

        $find_bot_step1 = str_replace(array('yandex', 'google', 'pinterest'), ' this_is_bot! ', $down_reg);
        $find_bot_step2 = explode(' ', $find_bot_step1);

        if (isset($find_bot_step2[1]) == "this_is_bot!") {

            return true;
       }

Here we catch an empty referrer and disable the cache (!empty($_SERVER["HTTP_REFERER"])) {

It is necessary to send all bots for verification, otherwise it will not work.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer