Add TCF v2.2 bridge mode for external CMP integration (v1.3.0)

New cmp_mode setting toggles between the built-in banner (default,
unchanged) and a bridge mode that defers banner UX to an external
IAB TCF v2.2 certified CMP — e.g. Google's free Privacy & messaging
(Funding Choices) or Tarteaucitron.js — and listens to __tcfapi to
keep custom-script gating, attribution preservation, the att_cc_consent
cookie cache and the WP Consent API bridge in sync. Lets sites that
need a Google-certified CMP for EEA/UK AdSense/AdMob serving keep
using this plugin for everything except the consent UI itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-30 14:10:58 +01:00
parent 7059c45e20
commit eb35fdabb6
7 changed files with 238 additions and 7 deletions

View File

@@ -16,6 +16,27 @@ if ( ! defined( 'ABSPATH' ) ) {
<input type="hidden" name="att_cc_tab" value="general">
<table class="form-table">
<tr>
<th scope="row">
<label for="cmp_mode"><?php esc_html_e( 'CMP Mode', 'att-consent' ); ?></label>
</th>
<td>
<select name="cmp_mode" id="cmp_mode">
<option value="self" <?php selected( $settings['cmp_mode'], 'self' ); ?>>
<?php esc_html_e( 'Built-in banner (default)', 'att-consent' ); ?>
</option>
<option value="tcf_bridge" <?php selected( $settings['cmp_mode'], 'tcf_bridge' ); ?>>
<?php esc_html_e( 'External TCF v2.2 CMP (e.g. Google Funding Choices, Tarteaucitron)', 'att-consent' ); ?>
</option>
</select>
<p class="description">
<?php
echo wp_kses_post( __( '<strong>Built-in banner:</strong> this plugin renders the consent banner and owns the consent decision.<br><strong>External TCF CMP:</strong> a separate, IAB TCF v2.2 certified CMP (such as Google\'s free Privacy &amp; messaging banner from AdSense, or Tarteaucitron.js) shows the banner and emits the official TC string. This plugin then listens to <code>__tcfapi</code>, maps TCF purposes to its three categories, and continues to run custom-script gating, attribution preservation and the WP Consent API bridge. Use this if you serve Google ads in EEA/UK/CH and need a certified CMP.', 'att-consent' ) );
?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="tracking_mode"><?php esc_html_e( 'Tracking Mode', 'att-consent' ); ?></label>