<?php
/*
 * Developed By Devozon
 *
 * Check Out at https://devozon.com/
 * Email: support@devozon.com
 * Message: https://www.facebook.com/devozon
 *
 * Please feel free to contact me at any time if you need a custom script or any development work.
 *
 * Devozon Team:
 * Coded by Sanad Nabil
 * Theme by Ahmed Reda
 * Tested By Smith Carter
 *
 * Devozon All rights reserved
 * Copyright (c) 2023-2025.
 * Last Update 22 \ 6 \ 2025
 */

if ( !defined( 'ABSPATH' ) ) {
	exit;
}

add_action( 'wp', 'FENSE_BPVT_detection', 0 );

add_action( 'login_init', 'FENSE_BPVT_detection', 0 );

add_action( 'login_form', 'FENSE_BPVT_detection', 0 );

add_action( 'muplugins_loaded', 'FENSE_BPVT_detection', 0 );
add_action( 'plugins_loaded', 'FENSE_BPVT_detection', 0 );

function FENSE_BPVT_detection()
{
	/**  Load Settings Class */
	$RUN = new FENSE_BPVT_RUN();
	
	/** Prevent Ajax Calls */
	if ( $RUN->__isAjaxCall() ) return null;
	
	/**  Disable on Logged in Or admin */
	if ( $RUN->__isAdminOrLoggedIn() ) return null;
	
	/**  RAN OPTIONS */
	if ( FENSE_BPVT_FUN::runOnce() ) return null;
	
	/**  Disable on Daily Limit Reached */
	if ( $RUN->__isDailyLimitReached() ) return null;
	
	/** Get Plugin License Key */
	if ( empty( $RUN->loadAppKey() ) ) return null;
	
	/** Get Visitor IP */
	if ( !$RUN->loadUserIp() ) return null;
	
	/** Exit if Plugin is Disabled */
	if ( !$RUN->loadSettings()->enable ) return null;
	
	/** Exit if Plugin Cache Exists */
	if ( $RUN->isCache() ) return null;
	
	/** Handle IP Whitelisting, Blacklisting Settings */
	if ( $RUN->__ipHandleWhitelistBlacklist() ) return true;
	
	/** Handle Bot */
	if ( $RUN->__isCrawlersBot() ) return null;
	
	/** Handle Plugin Page settings */
	if ( $RUN->__enableOn() ) return null;
	
	/** Get IP Data From Fense */
	$data = $RUN->loadData();
	
	/** Handle Plugin Blocked Domains Settings */
	if ( $RUN->__blockReferrerDomain() ) return $RUN->__blockReferrerDomain();
	
	/**  Exit if there was an error in API */
	if ( !empty( $data->status ) && in_array( $data->status, [ 'Error', 'error' ] ) ) return null;
	
	/** Handle Country Filters */
	if ( $RUN->__country() ) return $RUN->__country();
	
	/** Protection Code */
	return $RUN->__protection_mode();
}
