.cookieadmin-content-blocker{ position: relative; } .wp-block-embed__wrapper .cookieadmin-content-blocker, .ep-embed-content-wraper .cookieadmin-content-blocker, .elementor-widget-audio .cookieadmin-content-blocker, .elementor-widget-video .cookieadmin-content-blocker, .pagelayer-video-holder .cookieadmin-content-blocker { position: unset; } .wp-block-embed__wrapper.epyt-figure .cookieadmin-content-blocker{ position: relative; } .cookieadmin-content-thumbnail{ position:absolute; top:0; left:0; height:100%; width:100%; z-index:1; background-color:#999; } .cookieadmin-accept-content{ position:absolute; top:0; left:0; right:0; bottom:0; z-index:2; display:flex; justify-content:center; align-items:center; } .cookieadmin-accept-content div{ background:rgba(0,0,0,0.8); color:#fff; padding:10px 20px; border-radius:30px; font-size:14px; } '; } static function has_consent($preference = ''){ if(empty($_COOKIE['cookieadmin_consent'])){ return false; } $consent = json_decode(wp_unslash($_COOKIE['cookieadmin_consent']), true); if(empty($consent)){ return false; } if(!empty($consent['reject']) && ($consent['reject'] === 'true' || $consent['reject'] === true)){ return false; } if(!empty($consent['accept']) && ($consent['accept'] === 'true' || $consent['accept'] === true)){ return true; } if(!empty($preference)){ if(!empty($consent[$preference]) && ($consent[$preference] === 'true' || $consent[$preference] === true)){ return true; } } return false; } static function start_buffer(){ if(is_admin() || wp_doing_ajax()){ return false; } // Don't load this for REST API requests. if(defined('REST_REQUEST') && REST_REQUEST){ return; } // Start output buffer. ob_start([__CLASS__, 'process_html']); } static function process_html($html){ global $cookieadmin_settings; if(empty($html) || !is_string($html)){ return $html; } $html = self::block_embeds($html); return $html; } static function end_buffer(){ if(!empty(ob_get_length())){ ob_end_flush(); } } static function get_embed_services(){ return [ 'youtube' => [ 'name' => 'YouTube', 'category' => 'marketing', 'patterns' => ['youtube.com/embed', 'youtu.be/', 'youtube-nocookie.com'], ], 'vimeo' => [ 'name' => 'Vimeo', 'category' => 'marketing', 'patterns' => ['vimeo.com/video', 'player.vimeo.com'], ], 'dailymotion' => [ 'name' => 'Dailymotion', 'category' => 'marketing', 'patterns' => ['www.dailymotion.com/embed', 'geo.dailymotion.com/player.html'], ], 'soundcloud' => [ 'name' => 'SoundCloud', 'category' => 'marketing', 'patterns' => ['soundcloud.com/player', 'w.soundcloud.com'], ], 'maps' => [ 'name' => 'Google Maps', 'category' => 'marketing', 'patterns' => ['maps.google', 'maps.googleapis.com', 'google.com/maps', 'goo.gl/maps'], ], ]; } static function get_enabled_services(){ global $cookieadmin_settings; $key = 'content_blocking_services'; $enabled = !empty($cookieadmin_settings[$key]) ? $cookieadmin_settings[$key] : []; if(!is_array($enabled)){ $enabled = array_filter(array_map('trim', explode(',', $enabled))); } return $enabled; } static function find_matching_service($content, $services){ $content_lower = strtolower($content); foreach($services as $key => $service){ foreach($service['patterns'] as $pattern){ if(strpos($content_lower, strtolower($pattern)) !== false){ return [ 'service_key' => $key, 'service_name' => $service['name'], 'category' => $service['category'], ]; } } } return null; } static function block_embeds($html){ $enabled_services = self::get_enabled_services(); $services = self::get_embed_services(); if(!preg_match_all('/