{"id":34638676,"url":"https://github.com/generoi/genero-cmp","last_synced_at":"2025-12-24T17:12:39.125Z","repository":{"id":239776225,"uuid":"796784262","full_name":"generoi/genero-cmp","owner":"generoi","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-31T17:30:15.000Z","size":868,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-31T19:20:47.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/generoi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-06T16:12:46.000Z","updated_at":"2025-10-31T17:29:34.000Z","dependencies_parsed_at":"2024-05-20T17:17:14.873Z","dependency_job_id":"2133be69-263b-45f0-9a8d-c204b86fc01c","html_url":"https://github.com/generoi/genero-cmp","commit_stats":null,"previous_names":["generoi/genero-cmp"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/generoi/genero-cmp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generoi%2Fgenero-cmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generoi%2Fgenero-cmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generoi%2Fgenero-cmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generoi%2Fgenero-cmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/generoi","download_url":"https://codeload.github.com/generoi/genero-cmp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generoi%2Fgenero-cmp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28005414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T17:12:38.685Z","updated_at":"2025-12-24T17:12:39.116Z","avatar_url":"https://github.com/generoi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# genero-cmp\n\nCMP Plugin\n\n## Features\n\n- YouTube block use `youtube-noockie.com` domain instead\n- YouTube and Google Maps iframes require marketing and statistics consent before shown.\n- [Event Tracking for Gravity Forms](https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking/) container code is removed.\n- [Gravity Forms Analytics](https://www.gravityforms.com/add-ons/google-analytics/) analytics tag is removed.\n- [CTX Feed](https://wordpress.org/plugins/webappick-product-feed-for-woocommerce/) pixel is removed.\n- [WP Consent API](https://wordpress.org/plugins/wp-consent-api/) integration (required for GDPR compliant WooCommerce).\n- [TikTok for Business](https://wordpress.org/plugins/tiktok-for-business/) pixel is removed until marketing consent has been given\n- [Facebook for WooCommerce](https://wordpress.org/plugins/facebook-for-woocommerce/) pixel gets `fbq('consent', 'revoke');` when initialized\n\n## Block consent settings (beta)\n\nBlocks in the block editor are extended with an option to either hide/show based on one or multiple consents.\n\nNote this is likely broken in some cases at the moment.\n\n## PHP API\n\n### Define necessary cookies\n\nWhen withdrawing consent, all non-necessary cookies are removed. You can edit this set of cookies.\n\n```php\nadd_filter('gds_cmp_necessary_cookies', function (array $cookies) {\n    $cookies[] = CartServiceProvider::CART_COUNT_COOKIE;\n    $cookies[] = CartServiceProvider::LOGGED_IN_COOKIE;\n    return $cookies;\n});\n```\n\n### Alter consent categories\n\nYou can add or remove custom consent categories.\n\n```php\nadd_filter('gds_cmp_consents', function (array $consents) {\n    $consents[] = new \\GeneroWP\\GeneroCmp\\Models\\Consent(\n        id: 'custom-consent',\n        label: __('Custom Consent'),\n        description: __('Custom consent'),\n        wpConsentApiCategory: 'marketing',\n        gtmConsentModes: ['ad_storage', 'ad_user_data', 'ad_personalization'],\n    );\n    return $consents;\n});\n```\n\n\n### Block additional iframe embeds\n\nBy default iframes in `the_content` referencing _youtube.com_ get blocked using `\u003cgds-cmp-consent consent=\"marketing\"\u003e`. You can extend this to other iframe matches or all of them.\n\n```php\nadd_filter('gds_cmp_embed_consents', function (array $consents, string $tag) {\n  // Block all iframes by default\n  if (! $consents) {\n    $consents[] = 'preferences';\n  }\n  return $consents;\n}, 10, 2);\n```\n\n## JavaScript API\n\n```js\n/**\n * @param {HTMLElement} modal Reference to the \u003cgds-cmp-modal-dialog\u003e element\n * @returns {void}\n */\nwindow.gdsCmp.modal\n\n/**\n * Show the consent dialog\n *\n * @returns {void}\n */\nwindow.gdsCmp.show()\n\n/**\n * Hide the consent dialog\n *\n * @returns {void}\n */\nwindow.gdsCmp.hide()\n\n/**\n * Withdraw current consent.\n *\n * @returns {void}\n */\nwindow.gdsCmp.withdraw()\n\n/**\n * Return if user has granted the passed consents.\n *\n * @param {...Consent} consents Consent name eg. 'necessary`, `preferences`, `marketing`, `statistics`.\n * @returns {boolean} if user has granted all the consents\n */\nwindow.gdsCmp.hasConsent(...consents)\n\n/**\n * Evaluate and initialize all script tags using data-cmp-consent=\"\" string\n *\n * @param {Node} context\n * @returns void\n */\nwindow.gdsCmp.evaluateTags(context = document)\n```\n\n### Events\n\n```js\nwindow.addEventListener('gds-cmp.consent', () =\u003e {\n  if (window.gdsCmp.hasConsent('marketing')) {\n    // ....\n  }\n});\n\nwindow.addEventListener('gds-cmp.consent.marketing', () =\u003e {\n  // ...\n});\n```\n\n## Utilities\n\n### Hide content using CSS\n\n```html\n\u003cdiv data-gds-cmp-consent-optin=\"necessary marketing\"\u003e\n  Show when consent is given for necessary and marketing cookies.\n\u003c/div\u003e\n\u003cdiv data-gds-cmp-consent-optout=\"necessary marketing\"\u003e\n  Hide when consent is given for necessary and marketing cookies.\n\u003c/div\u003e\n```\n\n### Control cookie consent dialog\n\nAdd `.js-gds-cmp-show` class to any element (needs to be in DOM before DOMDocumentReady).\n\n```html\n\u003ca class=\"js-gds-cmp-show\"\u003eChange consent\u003c/a\u003e\n```\n\nAdd `[data-gds-cmp-trigger=\"show|hide|withdraw\"]` selector to any element (delegates as a document click listener)\n\n```html\n\u003cbutton data-gds-cmp-trigger=\"show\"\u003eChange consent\u003c/button\u003e\n```\n\n- Run manually with `window.gdsCmp.show()`\n- Run `show()` on the `\u003cgds-cmp-modal-dialog\u003e` element\n\n### Block elements from being loaded using `[data-gds-cmp-consent]` attribute\n\nYou can add `data-gds-cmp-consent=\"marketing preferences\"` to an element and once consent has been given, the element will evaluate.\n\nSupported elements are `\u003cscript\u003e`, `\u003cimg\u003e`, `\u003cvideo\u003e` and `\u003ciframe\u003e`.\n\nThis is useful if content is entirely opt-in and doesnt require prompting the user for consent.\n\n```html\n\u003cscript src=\"...\" type=\"text/plain\" data-gds-cmp-consent=\"marketing statistics\"\u003e\u003c/script\u003e\n\n\u003ciframe data-gds-cmp-src=\"...\" data-gds-cmp-consent=\"marketing\"\u003e\u003c/iframe\u003e\n\u003cimg data-gds-cmp-src=\"...\" data-gds-cmp-consent=\"marketing\" /\u003e\n\u003cvideo data-gds-cmp-src=\"...\" data-gds-cmp-consent=\"marketing\"\u003e\u003c/video\u003e\n```\n\n### Block elements with a message using `\u003cgds-cmp-embed\u003e`\n\n```html\n\u003cgds-cmp-embed\n  consent=\"{{ \\GeneroWP\\GeneroCmp\\Models\\Consent::MARKETING }}\"\n  description=\"{{ sprintf(__('Viewing this embed loads content from a third party and thus requires \u003cem\u003e%s\u003c/em\u003e consent.', 'wp-gds-theme'), __('Marketing', 'genero-cmp')) }}\"\n  button=\"{{ __('Modify preferences', 'genero-cmp') }}\"\n\u003e\n  Content which gets rendered once consent has been given.\n\u003c/gds-cmp-embed\u003e\n```\n\nYou can also use `as=\"\"` attribute to replace eg an `\u003ciframe\u003e`.\n\n```html\n\u003cgds-cmp-embed\n  as=\"iframe\"\n  consent=\"{{ \\GeneroWP\\GeneroCmp\\Models\\Consent::MARKETING }}\"\n  description=\"{{ sprintf(__('Viewing this embed loads content from a third party and thus requires \u003cem\u003e%s\u003c/em\u003e consent.', 'wp-gds-theme'), __('Marketing', 'genero-cmp')) }}\"\n  button=\"{{ __('Modify preferences', 'genero-cmp') }}\"\n  class=\"embed-youtube\"\n  frameborder=\"0\"\n  allowfullscreen=\"\"\n  allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n  src=\"https://www.youtube.com/embed/...\"\n\u003e\n\u003c/gds-cmp-embed\u003e\n```\n\nIf you need to run JS once the embed replace has taken place, you can listen for the `gds-cmp-embed.replaced` event.\n\n```js\nfunction init(el) {\n  if (el.tagName === 'GDS-CMP-EMBED') {\n    el.addEventListener('gds-cmp-embed.replaced', (e) =\u003e init(e.detail.element));\n    return;\n  }\n  // ... do stuff\n}\n\ninit(document.querySelector('[data-custom-function]'));\n```\n\n### GTM events\n\nWhenever users change consent the `gds-cmp.update` event will be sent to gtag. By creating a trigger for this event and adding it together with the _Consent initialization_ trigger, tags will run on the first page load after consent is updated.\n\n## Development\n\nInstall dependencies\n\n    composer install\n    npm install\n\nRun the tests\n\n    npm run test\n\nBuild assets\n\n    # Minified assets which are to be committed to git\n    npm run build:production\n\n    # Watch for changes and re-compile while developing the plugin\n    npm run start\n\n## Translations\n\n    wp i18n make-pot . languages/genero-cmp.pot\n    wp i18n make-mo languages/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeneroi%2Fgenero-cmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeneroi%2Fgenero-cmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeneroi%2Fgenero-cmp/lists"}