File: //wordpress/mu-plugins/wpcloud-bot-protection-loader.php
<?php
if ( ! function_exists( 'wpcloud_bot_protection_loader' ) ) {
function wpcloud_bot_protection_loader() {
if ( ! defined( 'ATOMIC_SITE_ID' ) || ! defined( 'ATOMIC_SITE_API_KEY' ) ) {
return;
}
if ( defined( 'WPC_BOT_PROTECTION_ENABLED' ) ) {
$mode = WPC_BOT_PROTECTION_ENABLED ? 'enforce' : 'off';
} elseif ( defined( 'AT_BOT_PROTECTION_ENABLED' ) && '' !== AT_BOT_PROTECTION_ENABLED ) {
$mode = AT_BOT_PROTECTION_ENABLED ? 'enforce' : 'off';
} else {
$client_rollout = array(
'129' => array(
'enforce' => 0,
'log' => 1000,
),
'2' => array(
'enforce' => 0,
'log' => 0,
),
);
$client_id = defined( 'ATOMIC_CLIENT_ID' ) ? (string) ATOMIC_CLIENT_ID : '';
if ( '' !== $client_id && isset( $client_rollout[ $client_id ] ) ) {
$bucket = (int) ATOMIC_SITE_ID % 1000;
$enforce = (int) $client_rollout[ $client_id ]['enforce'];
$log = (int) $client_rollout[ $client_id ]['log'];
if ( $bucket < $enforce ) {
$mode = 'enforce';
} elseif ( $bucket < $log ) {
$mode = 'log';
} else {
$mode = 'off';
}
} else {
$mode = 'off';
}
}
if ( ! apply_filters( 'wpcloud_bot_protection_enable', 'off' !== $mode ) ) {
$mode = 'off';
}
if ( 'off' === $mode ) {
return;
}
if ( ! defined( 'WPCLOUD_BOT_PROTECTION_MODE' ) ) {
define( 'WPCLOUD_BOT_PROTECTION_MODE', $mode );
}
$main = __DIR__ . '/wpcloud-bot-protection/wpcloud-bot-protection.php';
if ( file_exists( $main ) ) {
require_once $main;
}
}
add_action( 'plugins_loaded', 'wpcloud_bot_protection_loader', PHP_INT_MAX );
}