PHP code example of generoi / genero-cmp
1. Go to this page and download the library: Download generoi/genero-cmp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
generoi / genero-cmp example snippets
add_filter('gds_cmp_necessary_cookies', function (array $cookies) {
$cookies[] = CartServiceProvider::CART_COUNT_COOKIE;
$cookies[] = CartServiceProvider::LOGGED_IN_COOKIE;
return $cookies;
});
add_filter('gds_cmp_consents', function (array $consents) {
$consents[] = new \GeneroWP\GeneroCmp\Models\Consent(
id: 'custom-consent',
label: __('Custom Consent'),
description: __('Custom consent'),
wpConsentApiCategory: 'marketing',
gtmConsentModes: ['ad_storage', 'ad_user_data', 'ad_personalization'],
);
return $consents;
});
add_filter('gds_cmp_embed_consents', function (array $consents, string $tag) {
// Block all iframes by default
if (! $consents) {
$consents[] = 'preferences';
}
return $consents;
}, 10, 2);
js
window.addEventListener('gds-cmp.consent', () => {
if (window.gdsCmp.hasConsent('marketing')) {
// ....
}
});
window.addEventListener('gds-cmp.consent.marketing', () => {
// ...
});