File: /var/www/html/wp-content/plugins/advanced-ads-pro/includes/class-visitor-cookie.php
<?php
/**
* Visitor cookie template file.
* Brief description of the styles in this file
*
* @since 3.0.8
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Pro;
use AdvancedAds\Framework\Utilities\Str;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Visitor_Cookie class.
*/
class Visitor_Cookie implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
$this->maybe_set_visitor_cookie();
}
/**
* Set visitor cookie to true (allowed to be defined by JS) if explicitly allowed using filter or Cookiebot statistics consent
*
* @return void
*/
public function maybe_set_visitor_cookie(): void {
$cookie_consent = Params::cookie( 'CookieConsent' ) ?? '';
$statistics_consent = Str::contains( 'statistics:true', $cookie_consent );
$is_consent = $statistics_consent || apply_filters( 'advanced_ads_allow_visitor_cookie', false );
$value = '';
$expires = time() - 3600;
if ( $is_consent ) {
$value = '1';
$expires = time() + 3600;
}
setcookie( 'advanced_ads_visitor', $value, $expires, '/' );
}
}