Add filter to allow customisation of Consent Mode defaults.
Feature Description
At present, we provide the googlesitekit_consent_category_map filter to allow the mapping of CMP consent categories to Consent Mode parameters.
However, we don't provide a filter to allow customising the default consent values that are set. It would be useful to provide a filter so as to allow these defaults to be modified, thus allowing users complete control over the consent mode parameters.
https://github.com/google/site-kit-wp/blob/fe57e172dcdaa556fdfc7e010cb5577b6a605b91/includes/Core/Consent_Mode/Consent_Mode.php#L86-L101
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- A filter named
googlesitekit_consent_defaultsshould be added which allows the default consent parameters to be customised.
Implementation Brief
- [ ] Add
googlesitekit_consent_defaultsfilter for the default settings and pass current array as default value https://github.com/google/site-kit-wp/blob/fe57e172dcdaa556fdfc7e010cb5577b6a605b91/includes/Core/Consent_Mode/Consent_Mode.php#L86-L93$consent_defaults = apply_filters( 'googlesitekit_consent_defaults', array(...) );
Test Coverage
- No updates needed
QA Brief
Changelog entry
AC ✔️
IB ✅
QA Update: ⚠️
@ankitrox @techanvil this passes the QAB, but I have two questions:
- When the tiler is added I am assuming it should function with the
WP Consent APIplugin activated and disabled? I am sure it should but I do not want to assume. - Should we do any testing with the third-party consent plugins, e.g.
Complianzactivated? i suspect these plugins should override the filter we've added?
Hi @wpdarren, this filter is essentially independent of the WP Consent API plugin status and any existing third-party plugins.
It's purely there to allow modification of the default consent parameters that Site Kit sets when the Consent Mode feature is enabled. It's conceivable that some third party plugin may decide to integrate with it in future (I don't think this is particularly likely, but it's certainly possible), but in order to do so the plugin would need to write code to explicitly make use of the filter, which has obviously just been added and is not in a SK release yet so nobody outside of our team will have actually seen and used it as of yet.
QA Update: ✅
@techanvil thank you for the clarification there. I did think that would be the case, but wanted to double check.
Verified:
When no filter is added
- There is the snippet available on the page as per QAB.
When filter is added
- There is the snippet available on the page as per QAB for
Notice ad_storage,ad_user_dataandwait_for_updatebased on the filter used in the MU plugin.