Files
Testing/blog/wp-content/plugins/secureprivacy/admin/partials/prior-consent-partial.php
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

337 lines
15 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Provide a admin area view for the plugin
*
* This file is used to markup the admin-facing aspects of the plugin.
*
* @link http://secureprivacy.ai/
* @since 1.0.0
*
* @package Secureprivacy
* @subpackage Secureprivacy/admin/partials
*/
?>
<style>
.scanned-categories {
background: #f1f1f1;
border-radius: 4px;
padding: 10px;
margin-right: 0;
margin-bottom: 20px;
border: 1px solid #f1f1f1;
}
.btn-holder .border-default {
background: #fff;
}
.categoryHeading {
font-size: 14px;
padding: 0;
margin-bottom: 5px;
}
.btn-holder {
float: left;
margin-right: 10px;
margin-top: 10px;
}
</style>
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<div class="wrap _s" id="page_settings_page" style="display:none;">
<div class="col-sm-9">
<div class="sp-tabs-bar">
<a href="<?php echo admin_url('admin.php?page=dashboard'); ?>" class="customisation"> Dashboard </a>
<a href="<?php echo admin_url('admin.php?page=settings'); ?>" class="customisation"> Settings </a>
<a href="<?php echo admin_url('admin.php?page=banners'); ?>" class="customisation"> Banners </a>
<a href="<?php echo admin_url('admin.php?page=priorConsent'); ?>" class="customisation active-c"> Prior consent </a>
<!-- <a href="<?php echo admin_url('admin.php?page=privacyPolicy'); ?>" class="customisation"> Privacy policy </a> -->
<a href="<?php echo admin_url('admin.php?page=consentTracking'); ?>" class="customisation"> Consent tracking </a>
<span id="loading_span" style="display:none;margin-top:15px;margin-right:15px;" class="pull-right bs-label bg-blue">Loading...</span>
</div>
<div class="clearfix"></div>
<div style="border: solid 1px #dddddd;padding: 15px;background: #fff;">
<form action="javascript:void(0);" id="priorconsent-form">
<h4 class="settings-header" style="margin-bottom:20px;">Prior consent</h4>
<div class="alert alert-warning" style="display:none;overflow:hidden;margin-bottom:20px;" id="updrade_prior_consent">
<span style="line-height:34px;">Upgrade to block cookies from being loaded before you have received consent. <button class="pull-right btn btn-warning">Upgrade</a></span>
</div>
<div class="example-box-wrapper">
<ul id="nav_tabs_prior" class="nav-responsive nav nav-tabs">
<li class="active" id="li_tab_1" ><a href="javascript:void(0);" data-toggle="tab">Enable prior consent</a></li>
<li class="" id="li_tab_2"><a href="javascript:void(0);" data-toggle="tab">Configure your website</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<div id="prior_consent_panel"> </div>
</div>
<div class="tab-pane" id="tab2">
<div class="scanned-categories">
<ul>
<li>To enable prior consent, apply the attribute sp-consent="PLUGIN NAME" to target script/image tags on your website.</li>
<li>Set the values for these attributes from the list below.</li>
<li>For script tags change the attribute 'type' from 'text/javascript' to 'text/plain'</li>
<li>For script tags change the attribute 'src' from 'src' to 'data-src'</li>
</ul>
</div>
<div class="scanned-categories">
<ul>
<li>To enable prior consent with Google Tag Manager (GTM), you need to configure custom events that trigger the loading of plugins. Please follow this step by step <a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013137552-How-to-add-Prior-Consent-with-Google-Tag-Manager-GTM-" target="_blank">tutorial. </a></li>
</ul>
</div>
<div id="prior_consent_table"> </div>
</div>
</div>
<button id="btn_save_priorConsent_page" class="btn pull-right btn-success"> Save changes</button>
</div>
</form>
</div>
</div>
<div class="col-sm-3 information">
<div class="content-box">
<h3 class="content-box-header" style="background: #dddddd;">
Information
</h3>
<div class="content-box-wrapper support-articles">
<h2> Support</h2>
<a href="https://secureprivacysupport.zendesk.com/" target="_blank" class="btn btn-info">Get support</a>
<hr/>
<h2> Support articles</h2>
<div>
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013138852-How-to-add-privacy-policy-text-on-WordPress"
target="_blank" class="">How to add privacy policy text on WordPress</a>
</div>
<div>
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013137132-How-to-add-privacy-button-on-Wordpress-menu"
target="_blank" class="">How to add privacy button on Wordpress menu</a>
</div>
<div>
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360012912712-What-is-prior-consent-and-how-to-implement-it-"
target="_blank" class="">What is ‘prior consent’ and how to implement it?</a>
</div>
<div>
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013137552-How-to-add-Prior-Consent-with-Google-Tag-Manager-GTM-"
target="_blank" class="">How to add Prior Consent with Google Tag Manager (GTM)?</a>
</div>
<div>
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360015115112-Developer-guide-for-JavaScript-methods"
target="_blank" class="">Developer guide for JavaScript methods</a>
</div>
</div>
</div>
</div>
</div>
<form id="saveValueForm" action="options.php" method="post">
<?php
settings_fields( $this->plugin_name );
do_settings_sections( $this->plugin_name );
?>
</form>
<script>
//case of a fresh install
if (document.getElementById('outdated_notice_adminId').value === '' && document.getElementById('outdated_notice_sessionId').value === '') {
window.location.href = '<?php echo admin_url('admin.php?page=welcome'); ?>';
} else if (document.getElementById('outdated_notice_sessionId').value === '') {
window.location.href = '<?php echo admin_url('admin.php?page=login'); ?>';
} else {
document.getElementById('page_settings_page').style.display ='block';
}
getSupportedFeatures(window.document.getElementById('outdated_notice_planName').value);
(function ($) {
'use strict';
var editModalBanner, panel, table, allBannerTranslation;
$("#updrade_prior_consent button").on("click", function () {
window.sp_upgradePlan();
});
$('#loading_span').show();
$("#btn_save_priorConsent_page").prop("disabled", true);
$.ajax({
url: "<?php echo plugin_dir_url( __FILE__ ) . '../js/bannerTranslation.json'; ?>" ,
type: "GET",
contentType: 'application/json; charset=utf-8',
dataType: "json",
success: function (data) {
allBannerTranslation = data;
$.ajax({
url: window.sp_baseContext + '/api/banner?Domain=' + $('#outdated_notice_domainId').val(),
type: "GET",
headers: {
"Authorization": window.getAuthToken()
},
contentType: 'application/json; charset=utf-8',
dataType: "json",
success: function (allBanners) {
$("#settings-language-form :input").prop("disabled", false);
$("#btn_save_priorConsent_page").prop("disabled", false);
$('#loading_span').hide();
if (allBanners.length > 0) {
editModalBanner = allBanners[0];
}
createDivs();
},
error: function (e,x,v) {
if (e.status === 401) {
window.location.href = '<?php echo admin_url('admin.php?page=login'); ?>' + '&redirectTo=' + window.location.href + '&sessionExpired=true';
}
}
});
},
error: function (e,x,v) { }
});
function reversetoKeyword(translatedText, lang) {
var filterResult;
filterResult = allBannerTranslation.filter(function (l) {
return l.Language === lang && l.TranslatedText === translatedText;
});
if (filterResult && filterResult.length > 0) {
return filterResult[0].Keyword;
} else {
return translatedText;
}
}
function createDivs() {
panel = '';
table= '';
var isEnglish = false;
var selectedBannerLanguage;
for (var i = 0; i < editModalBanner.ComplianceLocalizedLists.length; i++) {
if (editModalBanner.ComplianceLocalizedLists[i].Localization === 'en') {
isEnglish = true;
break;
}
}
if (isEnglish === true) {
selectedBannerLanguage = 'en';
} else {
selectedBannerLanguage = editModalBanner.ComplianceLocalizedLists[0].Localization;
}
for (var i = 0; i < editModalBanner.ComplianceLocalizedLists.length; i++) {
var el = editModalBanner.ComplianceLocalizedLists[i];
if (el.Localization === selectedBannerLanguage && el.CategoyId !== 0 && reversetoKeyword(el.CategoyHeading, selectedBannerLanguage) !== "essential" && el.CategoyHeading !== "unclassified" && el.CategoyHeading !== "") {
panel += '<div class="scanned-categories" style = "overflow:hidden;">';
panel += '<div class="categoryHeading" style = "font-weight: bold;" >';
panel += '<span class="pull-right" style="padding-right:5px;cursor: default;">';
if (el.IsMandatory) {
panel += '<input checked="checked" class="chk_priorconsent" id="chk_priorconsent-'+ el.CategoyId+'" type="checkbox"> Enable prior consent';
} else {
panel += '<input class="chk_priorconsent" id="chk_priorconsent-'+ el.CategoyId+'" type="checkbox"> Enable prior consent';
}
panel += '</span>';
panel += el.CategoyHeading + '</div> <span> ' ;
for (var j = 0; j < el.PluginList.length; j++) {
var pl = el.PluginList[j];
panel += '<div class="btn-holder btn-group"> <button class = "btn border-default btn-link font-black btn-sm" style="cursor:default;" type = "button">' + pl.ComplianceType + '</button> </div>';
if (el.IsMandatory) {
table += '<tr><th>'+pl.ComplianceType+'</th><th><code>sp-consent="sp-consent'+pl.ComplianceType+'"</code></th></tr>';
}
}
panel += ' </span>';
panel += '</div >';
}
}
$('#prior_consent_panel').html(panel);
if (table === '') {
table= '<tr><td colspan="2">Prior consent not enabled</td></tr>';
}
$('#prior_consent_table').html('<table class="table"><tr><th>Name of plugin/tracker</th><th>Attribute</th></tr> '+ table + '</table>');
if (window.sp_supportedFeatures.priorConsent === false) {
$(".chk_priorconsent").prop("disabled", true);
$("#btn_save_priorConsent_page").prop("disabled", true);
$("#nav_tabs_prior").hide();
$("#updrade_prior_consent").show();
}
}
$("#li_tab_1").on("click", function () {
$('#li_tab_1').addClass('active');
$('#tab1').addClass('active');
$('#li_tab_2').removeClass('active');
$('#tab2').removeClass('active');
});
$("#li_tab_2").on("click", function () {
if (window.sp_supportedFeatures.priorConsent === true) {
$('#li_tab_2').addClass('active');
$('#tab2').addClass('active');
$('#li_tab_1').removeClass('active');
$('#tab1').removeClass('active');
$("#updrade_prior_consent").hide();
}
});
$("#btn_save_priorConsent_page").on("click", function () {
$("#btn_save_priorConsent_page").prop("disabled", true);
$("#btn_save_priorConsent_page").text("Saving");
$(".chk_priorconsent").each(function() {
if (this.checked) {
var id = this.id.split('-')[1];
for (var i = 0; i < editModalBanner.ComplianceLocalizedLists.length; i++) {
var el = editModalBanner.ComplianceLocalizedLists[i];
if (el.CategoyId.toString() === id.toString()) {
el.IsMandatory = true;
}
}
} else {
var id = this.id.split('-')[1];
for (var i = 0; i < editModalBanner.ComplianceLocalizedLists.length; i++) {
var el = editModalBanner.ComplianceLocalizedLists[i];
if (el.CategoyId.toString() === id.toString()) {
el.IsMandatory = false;
}
}
}
});
updateBanner();
});
function updateBanner() {
editModalBanner.Domain = $('#outdated_notice_domainId').val();
$.ajax({
url: window.sp_baseContext + '/api/banner' ,
type: "PUT",
headers: {
"Authorization": window.getAuthToken()
},
data: JSON.stringify(editModalBanner),
contentType: 'application/json; charset=utf-8',
dataType: "json",
success: function (data) {
createDivs();
alert('Saved successfully');
$("#btn_save_priorConsent_page").prop("disabled", false);
$("#btn_save_priorConsent_page").text("Save changes");
},
error: function (e,x,v) {
}
});
}
window.resetPlan(false);
})(jQuery);
</script>