Files
att-consent/admin/views/settings-general.php
Steve Hanlon 4adda0ded7 Add consent reopener: floating widget + anchor link trigger
Allow visitors to reopen the cookie preferences modal after making
their choice via a configurable floating button (bottom-right or
right-side vertical) or any anchor link with href="#att-cc-preferences".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 06:13:55 +00:00

157 lines
5.5 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">
<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>