Last active
February 26, 2024 13:42
-
-
Save Yiannistaos/5c255bd3c058c219d13dbd98a7614a7a to your computer and use it in GitHub Desktop.
How to block youtube, vimeo, and other cookies from video providers by using the Cookies Policy Notification Bar Joomla! plugin, and the AllVideos Joomla! plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @version 6.1.0 | |
* @package AllVideos (plugin) | |
* @author JoomlaWorks - https://www.joomlaworks.net | |
* @copyright Copyright (c) 2006 - 2020 JoomlaWorks Ltd. All rights reserved. | |
* @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html | |
* This AllVideos template is compatible with the Cookies Policy Notification Bar - Joomla! plugin by Web357.com | |
*/ | |
// no direct access | |
defined('_JEXEC') or die('Restricted access'); | |
// BEGIN: Check if Cookies are accepted from the User (Compatible with Cookies Policy Notification Bar - Joomla! plugin by Web357.com) | |
// get cookies from browser | |
$jcookies = JFactory::getApplication()->input->cookie->getArray(); // $_COOKIE | |
// get plugin's parameters | |
jimport('joomla.plugin.helper'); | |
$cookiespolicynotificationbar = JPluginHelper::getPlugin('system', 'cookiespolicynotificationbar'); | |
$cpnb_params = new JRegistry($cookiespolicynotificationbar->params); | |
$cpnb_cookie_name = $cpnb_params->get('cookie_name', 'cookiesDirective'); | |
// Block video cookies from specific categories | |
# $cpnb_specific_cookie_category_name_to_be_blocked = 'video-cookies'; | |
# $cpnb_cookiesSettings = $jcookies['cpnb_cookiesSettings']; | |
# $cpnb_cookiesSettings_arr = json_decode($cpnb_cookiesSettings, true); | |
# $cpnb_specific_cookies_category_accepted = $cpnb_cookiesSettings_arr[$cpnb_specific_cookie_category_name_to_be_blocked]; | |
if (isset($jcookies[$cpnb_cookie_name])) | |
# if (isset($jcookies[$cpnb_cookie_name]) && $cpnb_specific_cookies_category_accepted) | |
{ | |
$cookies_accepted = true; | |
} | |
else | |
{ | |
$cookies_accepted = false; | |
} | |
// END: Check if Cookies are accepted from the User | |
?> | |
<?php if ($cookies_accepted === FALSE): ?> | |
<div class="cpnb-accept-first-message"> | |
<p><?php echo JText::_('The video cannot be displayed because you have to accept the cookies first.'); ?></p> | |
</div> | |
<?php endif; ?> | |
<?php if ($cookies_accepted === TRUE): ?> | |
<div class="avPlayerWrapper<?php echo $output->mediaTypeClass; ?>"> | |
<div class="avPlayerContainer"<?php echo $maxwidth; ?>> | |
<div id="<?php echo $output->playerID; ?>" class="avPlayerBlock"> | |
<?php echo $output->player; ?> | |
</div> | |
<?php if (($allowVideoDownloading && $output->mediaType == 'video') || ($allowAudioDownloading && $output->mediaType == 'audio')): ?> | |
<div class="avDownloadLink"> | |
<a target="_blank" href="<?php echo $output->source; ?>" download><?php echo JText::_('JW_PLG_AV_DOWNLOAD'); ?></a> | |
</div> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Yiannistaos
I just wanted to point out that JoomlaWorks has enabled a privacy mode switch in the latest version.
Its using the co-cookie domain from Youtube.