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>
194 lines
7.4 KiB
PHP
194 lines
7.4 KiB
PHP
<?php
|
|
/**
|
|
* General settings tab.
|
|
*
|
|
* @package ATT_Consent
|
|
* @var array $settings Current settings.
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
?>
|
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
|
<?php wp_nonce_field( 'att_cc_save_settings' ); ?>
|
|
<input type="hidden" name="action" value="att_cc_save_settings">
|
|
<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 & 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>
|
|
</th>
|
|
<td>
|
|
<select name="tracking_mode" id="tracking_mode">
|
|
<option value="gtag" <?php selected( $settings['tracking_mode'], 'gtag' ); ?>>
|
|
<?php esc_html_e( 'Google Analytics (gtag.js)', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="gtm" <?php selected( $settings['tracking_mode'], 'gtm' ); ?>>
|
|
<?php esc_html_e( 'Google Tag Manager', 'att-consent' ); ?>
|
|
</option>
|
|
</select>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Choose whether to inject gtag.js directly or use a GTM container.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class="att-cc-gtag-row">
|
|
<th scope="row">
|
|
<label for="ga4_measurement_id"><?php esc_html_e( 'GA4 Measurement ID', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<input type="text" name="ga4_measurement_id" id="ga4_measurement_id"
|
|
value="<?php echo esc_attr( $settings['ga4_measurement_id'] ); ?>"
|
|
class="regular-text" placeholder="G-XXXXXXXXXX">
|
|
<p class="description">
|
|
<?php esc_html_e( 'Your GA4 Measurement ID (starts with G-).', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class="att-cc-gtm-row">
|
|
<th scope="row">
|
|
<label for="gtm_container_id"><?php esc_html_e( 'GTM Container ID', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<input type="text" name="gtm_container_id" id="gtm_container_id"
|
|
value="<?php echo esc_attr( $settings['gtm_container_id'] ); ?>"
|
|
class="regular-text" placeholder="GTM-XXXXXXX">
|
|
<p class="description">
|
|
<?php esc_html_e( 'Your Google Tag Manager Container ID (starts with GTM-).', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="consent_mode"><?php esc_html_e( 'Consent Mode', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<select name="consent_mode" id="consent_mode">
|
|
<option value="advanced" <?php selected( $settings['consent_mode'], 'advanced' ); ?>>
|
|
<?php esc_html_e( 'Advanced (recommended)', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="basic" <?php selected( $settings['consent_mode'], 'basic' ); ?>>
|
|
<?php esc_html_e( 'Basic', 'att-consent' ); ?>
|
|
</option>
|
|
</select>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Advanced: Tags load before consent, sending cookieless pings for better modelling. Basic: No tags load until consent is given.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="banner_position"><?php esc_html_e( 'Banner Position', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<select name="banner_position" id="banner_position">
|
|
<option value="bottom" <?php selected( $settings['banner_position'], 'bottom' ); ?>>
|
|
<?php esc_html_e( 'Bottom Bar', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="top" <?php selected( $settings['banner_position'], 'top' ); ?>>
|
|
<?php esc_html_e( 'Top Bar', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="center" <?php selected( $settings['banner_position'], 'center' ); ?>>
|
|
<?php esc_html_e( 'Centre Modal', 'att-consent' ); ?>
|
|
</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<?php esc_html_e( 'Global gtag Function', 'att-consent' ); ?>
|
|
</th>
|
|
<td>
|
|
<label for="expose_gtag_global">
|
|
<input type="checkbox" name="expose_gtag_global" id="expose_gtag_global" value="1"
|
|
<?php checked( $settings['expose_gtag_global'] ); ?>>
|
|
<?php esc_html_e( 'Expose window.gtag() globally', 'att-consent' ); ?>
|
|
</label>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Enable this if other plugins or custom scripts on your site call gtag() directly (e.g. HFCM snippets). When disabled, only window.attCCGtag() is available.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="floating_widget"><?php esc_html_e( 'Floating Widget', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<select name="floating_widget" id="floating_widget">
|
|
<option value="bottom-right" <?php selected( $settings['floating_widget'], 'bottom-right' ); ?>>
|
|
<?php esc_html_e( 'Bottom Right (recommended)', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="right" <?php selected( $settings['floating_widget'], 'right' ); ?>>
|
|
<?php esc_html_e( 'Right Side (vertical)', 'att-consent' ); ?>
|
|
</option>
|
|
<option value="none" <?php selected( $settings['floating_widget'], 'none' ); ?>>
|
|
<?php esc_html_e( 'Disabled', 'att-consent' ); ?>
|
|
</option>
|
|
</select>
|
|
<p class="description">
|
|
<?php esc_html_e( 'A small floating button that allows visitors to reopen the cookie preferences modal after they\'ve made their choice.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="floating_widget_label"><?php esc_html_e( 'Floating Widget Label', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<input type="text" name="floating_widget_label" id="floating_widget_label"
|
|
value="<?php echo esc_attr( $settings['floating_widget_label'] ); ?>"
|
|
class="regular-text">
|
|
<p class="description">
|
|
<?php esc_html_e( 'Text shown on the floating widget button.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="consent_expiry"><?php esc_html_e( 'Consent Expiry (days)', 'att-consent' ); ?></label>
|
|
</th>
|
|
<td>
|
|
<input type="number" name="consent_expiry" id="consent_expiry"
|
|
value="<?php echo esc_attr( $settings['consent_expiry'] ); ?>"
|
|
class="small-text" min="1" max="730">
|
|
<p class="description">
|
|
<?php esc_html_e( 'How long the consent cookie lasts before the user is asked again.', 'att-consent' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php submit_button(); ?>
|
|
</form>
|