New checkbox in General settings to conditionally expose window.gtag() for compatibility with third-party scripts (e.g. HFCM). Defaults to off, keeping only window.attCCGtag() available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
173 lines
6.1 KiB
PHP
173 lines
6.1 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="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>
|