From 68e7a6ac35b983aa00f3c55000102ad31312b32b Mon Sep 17 00:00:00 2001 From: Steve Hanlon Date: Tue, 30 Jun 2026 14:55:28 +0100 Subject: [PATCH] Fix TCF bridge widget click for Google Funding Choices (v1.3.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FC accepts the IAB __tcfapi('displayConsentUi', 2, …) command without throwing but silently no-ops, which caused the previous order (IAB first, FC-specific fallback second) to swallow the click. Reorder so that googlefc.showRevocationMessage() is tried first whenever window.googlefc is present, with the IAB call kept as the fallback for non-FC CMPs (Sourcepoint, Didomi, etc). Co-Authored-By: Claude Opus 4.7 (1M context) --- att-consent.php | 4 ++-- public/js/tcf-bridge.js | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/att-consent.php b/att-consent.php index 2078960..7484df1 100644 --- a/att-consent.php +++ b/att-consent.php @@ -3,7 +3,7 @@ * Plugin Name: ATT Consent * Plugin URI: https://github.com/att-consent/att-consent * Description: Google Consent Mode v2 cookie consent with session attribution preservation, custom script management, and full gtag.js/GTM support. - * Version: 1.3.0 + * Version: 1.3.1 * Requires at least: 6.0 * Requires PHP: 7.4 * Author: ATT Consent @@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -define( 'ATT_CC_VERSION', '1.3.0' ); +define( 'ATT_CC_VERSION', '1.3.1' ); define( 'ATT_CC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'ATT_CC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'ATT_CC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); diff --git a/public/js/tcf-bridge.js b/public/js/tcf-bridge.js index f127d65..16aef3c 100644 --- a/public/js/tcf-bridge.js +++ b/public/js/tcf-bridge.js @@ -103,15 +103,12 @@ widget.addEventListener('click', function (e) { e.preventDefault(); - // 1. Standard IAB way (works for any compliant TCF v2.2 CMP). - if (typeof window.__tcfapi === 'function') { - try { - window.__tcfapi('displayConsentUi', 2, function () {}); - return; - } catch (err) {} + // 1. Google Funding Choices: use its own re-prompt API. + // FC accepts but silently ignores the IAB 'displayConsentUi' + // command, so we must try the FC path FIRST when FC is detected. + if (window.googlefc && typeof window.googlefc.showRevocationMessage === 'function') { + try { window.googlefc.showRevocationMessage(); return; } catch (err) {} } - - // 2. Google Funding Choices specific re-prompt. if (window.googlefc && window.googlefc.callbackQueue) { window.googlefc.callbackQueue.push({ CONSENT_DATA_READY: function () { @@ -123,6 +120,12 @@ return; } + // 2. Generic IAB TCF v2.2 re-prompt — for non-FC CMPs that + // actually implement this (Sourcepoint, Didomi, etc.). + if (typeof window.__tcfapi === 'function') { + try { window.__tcfapi('displayConsentUi', 2, function () {}); return; } catch (err) {} + } + // 3. Last-ditch: scroll to a #privacy / #cookies anchor if the // site has one in its footer. Fail silently otherwise. var fallback = document.querySelector('a[href*="#cookie"], a[href*="#privacy"]');