| 1 |
<?php |
| 2 |
/** |
| 3 |
* Cookie / Consent Bar admin page - V3 Premium style inspired Design. |
| 4 |
* |
| 5 |
* @var array<string, mixed> $options |
| 6 |
* @var bool $is_premium |
| 7 |
* @package King_Addons |
| 8 |
*/ |
| 9 |
|
| 10 |
if (!defined('ABSPATH')) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
// Enqueue shared V3 styles |
| 15 |
wp_enqueue_style( |
| 16 |
'king-addons-admin-v3', |
| 17 |
KING_ADDONS_URL . 'includes/admin/layouts/shared/admin-v3-styles.css', |
| 18 |
[], |
| 19 |
KING_ADDONS_VERSION |
| 20 |
); |
| 21 |
|
| 22 |
// Enqueue WP color picker |
| 23 |
wp_enqueue_style('wp-color-picker'); |
| 24 |
wp_enqueue_script('wp-color-picker'); |
| 25 |
|
| 26 |
$notices = []; |
| 27 |
if (isset($_GET['updated'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 28 |
$notices[] = esc_html__('Settings saved.', 'king-addons'); |
| 29 |
} |
| 30 |
if (isset($_GET['imported'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 31 |
$notices[] = esc_html__('Settings imported.', 'king-addons'); |
| 32 |
} |
| 33 |
if (isset($_GET['logs_cleared'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 34 |
$notices[] = esc_html__('Logs cleared.', 'king-addons'); |
| 35 |
} |
| 36 |
|
| 37 |
$categories = $options['categories']; |
| 38 |
$empty_slots = $is_premium ? 2 : 1; |
| 39 |
for ($i = 0; $i < $empty_slots; $i++) { |
| 40 |
$categories[] = [ |
| 41 |
'key' => '', |
| 42 |
'label' => '', |
| 43 |
'description' => '', |
| 44 |
'state' => 'off', |
| 45 |
'display' => true, |
| 46 |
]; |
| 47 |
} |
| 48 |
|
| 49 |
$script_rules = $options['scripts']; |
| 50 |
if (count($script_rules) < 3) { |
| 51 |
$script_rules = array_merge($script_rules, array_fill(0, 3 - count($script_rules), [ |
| 52 |
'handle' => '', |
| 53 |
'category' => 'analytics', |
| 54 |
'mode' => 'block', |
| 55 |
])); |
| 56 |
} |
| 57 |
|
| 58 |
// Theme mode is per-user |
| 59 |
$theme_mode = get_user_meta(get_current_user_id(), 'king_addons_theme_mode', true); |
| 60 |
$allowed_theme_modes = ['dark', 'light', 'auto']; |
| 61 |
if (!in_array($theme_mode, $allowed_theme_modes, true)) { |
| 62 |
$theme_mode = 'dark'; |
| 63 |
} |
| 64 |
?> |
| 65 |
<script> |
| 66 |
(function() { |
| 67 |
const mode = '<?php echo esc_js($theme_mode); ?>'; |
| 68 |
const mql = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null; |
| 69 |
const isDark = mode === 'auto' ? !!(mql && mql.matches) : mode === 'dark'; |
| 70 |
document.documentElement.classList.toggle('ka-v3-dark', isDark); |
| 71 |
document.body && document.body.classList.add('ka-admin-v3'); |
| 72 |
document.body && document.body.classList.toggle('ka-v3-dark', isDark); |
| 73 |
})(); |
| 74 |
</script> |
| 75 |
|
| 76 |
<div class="ka-admin-wrap"> |
| 77 |
<!-- Header --> |
| 78 |
<div class="ka-admin-header"> |
| 79 |
<div class="ka-admin-header-left"> |
| 80 |
<div class="ka-admin-header-icon"> |
| 81 |
<span class="dashicons dashicons-shield"></span> |
| 82 |
</div> |
| 83 |
<div> |
| 84 |
<h1 class="ka-admin-title"><?php esc_html_e('Cookie Consent', 'king-addons'); ?></h1> |
| 85 |
<p class="ka-admin-subtitle"><?php esc_html_e('GDPR & CCPA compliant consent management', 'king-addons'); ?></p> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
<div class="ka-admin-header-actions"> |
| 89 |
<span class="ka-status <?php echo $options['enabled'] ? 'ka-status-enabled' : 'ka-status-disabled'; ?>"> |
| 90 |
<span class="ka-status-dot"></span> |
| 91 |
<?php echo $options['enabled'] ? esc_html__('Enabled', 'king-addons') : esc_html__('Disabled', 'king-addons'); ?> |
| 92 |
</span> |
| 93 |
<div class="ka-v3-segmented" id="ka-v3-theme-segment" role="radiogroup" aria-label="Theme" data-active="<?php echo esc_attr($theme_mode); ?>"> |
| 94 |
<span class="ka-v3-segmented-indicator" aria-hidden="true"></span> |
| 95 |
<button type="button" class="ka-v3-segmented-btn" data-theme="light" aria-pressed="<?php echo $theme_mode === 'light' ? 'true' : 'false'; ?>"> |
| 96 |
<span class="ka-v3-segmented-icon" aria-hidden="true">☀︎</span> |
| 97 |
<?php esc_html_e('Light', 'king-addons'); ?> |
| 98 |
</button> |
| 99 |
<button type="button" class="ka-v3-segmented-btn" data-theme="dark" aria-pressed="<?php echo $theme_mode === 'dark' ? 'true' : 'false'; ?>"> |
| 100 |
<span class="ka-v3-segmented-icon" aria-hidden="true">☾</span> |
| 101 |
<?php esc_html_e('Dark', 'king-addons'); ?> |
| 102 |
</button> |
| 103 |
<button type="button" class="ka-v3-segmented-btn" data-theme="auto" aria-pressed="<?php echo $theme_mode === 'auto' ? 'true' : 'false'; ?>"> |
| 104 |
<span class="ka-v3-segmented-icon" aria-hidden="true">◐</span> |
| 105 |
<?php esc_html_e('Auto', 'king-addons'); ?> |
| 106 |
</button> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
|
| 111 |
<!-- Notices --> |
| 112 |
<?php foreach ($notices as $notice): ?> |
| 113 |
<div class="ka-card" style="background: rgba(52, 199, 89, 0.1); border: 1px solid rgba(52, 199, 89, 0.3); margin-bottom: 20px;"> |
| 114 |
<div class="ka-card-body" style="padding: 16px 24px; display: flex; align-items: center; gap: 12px;"> |
| 115 |
<span class="dashicons dashicons-yes-alt" style="color: #34c759;"></span> |
| 116 |
<span style="color: #34c759; font-weight: 500;"><?php echo esc_html($notice); ?></span> |
| 117 |
</div> |
| 118 |
</div> |
| 119 |
<?php endforeach; ?> |
| 120 |
|
| 121 |
<!-- Tabs --> |
| 122 |
<div class="ka-tabs"> |
| 123 |
<button type="button" class="ka-tab active" data-tab="general"><?php esc_html_e('General', 'king-addons'); ?></button> |
| 124 |
<button type="button" class="ka-tab" data-tab="content"><?php esc_html_e('Content', 'king-addons'); ?></button> |
| 125 |
<button type="button" class="ka-tab" data-tab="categories"><?php esc_html_e('Categories', 'king-addons'); ?></button> |
| 126 |
<button type="button" class="ka-tab" data-tab="design"><?php esc_html_e('Design', 'king-addons'); ?></button> |
| 127 |
<button type="button" class="ka-tab" data-tab="scripts"><?php esc_html_e('Scripts', 'king-addons'); ?></button> |
| 128 |
<button type="button" class="ka-tab" data-tab="behavior"><?php esc_html_e('Behavior', 'king-addons'); ?></button> |
| 129 |
<button type="button" class="ka-tab" data-tab="advanced"><?php esc_html_e('Advanced', 'king-addons'); ?></button> |
| 130 |
<button type="button" class="ka-tab" data-tab="logs"> |
| 131 |
<?php esc_html_e('Logs', 'king-addons'); ?> |
| 132 |
<?php if (!$is_premium): ?><span class="ka-pro-badge">PRO</span><?php endif; ?> |
| 133 |
</button> |
| 134 |
</div> |
| 135 |
|
| 136 |
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> |
| 137 |
<?php wp_nonce_field('king_addons_cookie_consent_save'); ?> |
| 138 |
<input type="hidden" name="action" value="king_addons_cookie_consent_save"> |
| 139 |
|
| 140 |
<!-- General Tab --> |
| 141 |
<div class="ka-tab-content active" data-tab="general"> |
| 142 |
<div class="ka-card"> |
| 143 |
<div class="ka-card-header"> |
| 144 |
<span class="dashicons dashicons-admin-settings"></span> |
| 145 |
<h2><?php esc_html_e('General Settings', 'king-addons'); ?></h2> |
| 146 |
</div> |
| 147 |
<div class="ka-card-body"> |
| 148 |
<div class="ka-row"> |
| 149 |
<div class="ka-row-label"><?php esc_html_e('Enable', 'king-addons'); ?></div> |
| 150 |
<div class="ka-row-field"> |
| 151 |
<label class="ka-toggle"> |
| 152 |
<input type="checkbox" name="enabled" value="1" <?php checked($options['enabled']); ?>> |
| 153 |
<span class="ka-toggle-slider"></span> |
| 154 |
<span class="ka-toggle-label"><?php esc_html_e('Show consent banner', 'king-addons'); ?></span> |
| 155 |
</label> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
<div class="ka-row"> |
| 159 |
<div class="ka-row-label"><?php esc_html_e('Mode', 'king-addons'); ?></div> |
| 160 |
<div class="ka-row-field"> |
| 161 |
<select name="mode"> |
| 162 |
<option value="gdpr" <?php selected($options['mode'], 'gdpr'); ?>><?php esc_html_e('GDPR (EU)', 'king-addons'); ?></option> |
| 163 |
<option value="ccpa" <?php selected($options['mode'], 'ccpa'); ?>><?php esc_html_e('CCPA (California)', 'king-addons'); ?></option> |
| 164 |
<option value="simple" <?php selected($options['mode'], 'simple'); ?>><?php esc_html_e('Simple banner', 'king-addons'); ?></option> |
| 165 |
</select> |
| 166 |
</div> |
| 167 |
</div> |
| 168 |
<div class="ka-row"> |
| 169 |
<div class="ka-row-label"><?php esc_html_e('Region', 'king-addons'); ?></div> |
| 170 |
<div class="ka-row-field"> |
| 171 |
<select name="region_targeting" id="kng-cookie-region-targeting" <?php disabled(!$is_premium && $options['region_targeting'] !== 'all'); ?>> |
| 172 |
<option value="all" <?php selected($options['region_targeting'], 'all'); ?>><?php esc_html_e('All visitors', 'king-addons'); ?></option> |
| 173 |
<option value="eu" <?php selected($options['region_targeting'], 'eu'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('EU only', 'king-addons'); ?></option> |
| 174 |
<option value="us" <?php selected($options['region_targeting'], 'us'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('US only', 'king-addons'); ?></option> |
| 175 |
<option value="custom" <?php selected($options['region_targeting'], 'custom'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('Custom', 'king-addons'); ?></option> |
| 176 |
</select> |
| 177 |
<?php if (!$is_premium): ?> |
| 178 |
<p class="ka-row-desc"><?php esc_html_e('Pro: Geo-targeting with cached lookup', 'king-addons'); ?></p> |
| 179 |
<?php endif; ?> |
| 180 |
</div> |
| 181 |
</div> |
| 182 |
|
| 183 |
<?php if ($is_premium): ?> |
| 184 |
<div class="ka-row" id="kng-cookie-custom-regions-row" style="<?php echo ($options['region_targeting'] ?? 'all') === 'custom' ? '' : 'display:none;'; ?>"> |
| 185 |
<div class="ka-row-label"><?php esc_html_e('Custom regions', 'king-addons'); ?></div> |
| 186 |
<div class="ka-row-field"> |
| 187 |
<textarea name="custom_regions" rows="2" placeholder="eu, us, CA, AU" style="width: 100%; max-width: 520px;"><?php echo esc_textarea($options['custom_regions'] ?? ''); ?></textarea> |
| 188 |
<p class="ka-row-desc"><?php esc_html_e('Comma-separated list. Use “eu” for EU, “us” for United States, and ISO-2 codes for other countries (e.g. CA, AU).', 'king-addons'); ?></p> |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
<?php endif; ?> |
| 192 |
<div class="ka-row"> |
| 193 |
<div class="ka-row-label"><?php esc_html_e('Consent Lifetime', 'king-addons'); ?></div> |
| 194 |
<div class="ka-row-field"> |
| 195 |
<select name="consent_lifetime"> |
| 196 |
<option value="30" <?php selected($options['consent_lifetime'], '30'); ?>><?php esc_html_e('1 month', 'king-addons'); ?></option> |
| 197 |
<option value="90" <?php selected($options['consent_lifetime'], '90'); ?>><?php esc_html_e('3 months', 'king-addons'); ?></option> |
| 198 |
<option value="180" <?php selected($options['consent_lifetime'], '180'); ?>><?php esc_html_e('6 months', 'king-addons'); ?></option> |
| 199 |
<option value="365" <?php selected($options['consent_lifetime'], '365'); ?>><?php esc_html_e('1 year', 'king-addons'); ?></option> |
| 200 |
</select> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
<div class="ka-row"> |
| 204 |
<div class="ka-row-label"><?php esc_html_e('Policy Version', 'king-addons'); ?></div> |
| 205 |
<div class="ka-row-field"> |
| 206 |
<input type="text" name="policy_version" value="<?php echo esc_attr($options['policy_version']); ?>" style="max-width: 100px;"> |
| 207 |
<p class="ka-row-desc"><?php esc_html_e('Increase to re-show banner after policy update', 'king-addons'); ?></p> |
| 208 |
</div> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
</div> |
| 212 |
</div> |
| 213 |
|
| 214 |
<script> |
| 215 |
document.addEventListener('DOMContentLoaded', function() { |
| 216 |
var select = document.getElementById('kng-cookie-region-targeting'); |
| 217 |
var row = document.getElementById('kng-cookie-custom-regions-row'); |
| 218 |
if (!select || !row) return; |
| 219 |
var toggle = function() { |
| 220 |
row.style.display = (select.value === 'custom') ? '' : 'none'; |
| 221 |
}; |
| 222 |
select.addEventListener('change', toggle); |
| 223 |
toggle(); |
| 224 |
}); |
| 225 |
</script> |
| 226 |
|
| 227 |
<!-- Content Tab --> |
| 228 |
<div class="ka-tab-content" data-tab="content"> |
| 229 |
<div class="ka-card"> |
| 230 |
<div class="ka-card-header"> |
| 231 |
<span class="dashicons dashicons-edit"></span> |
| 232 |
<h2><?php esc_html_e('Banner Content', 'king-addons'); ?></h2> |
| 233 |
</div> |
| 234 |
<div class="ka-card-body"> |
| 235 |
<div class="ka-row"> |
| 236 |
<div class="ka-row-label"><?php esc_html_e('Template', 'king-addons'); ?></div> |
| 237 |
<div class="ka-row-field"> |
| 238 |
<select name="template"> |
| 239 |
<option value="gdpr_minimal" <?php selected($options['template'], 'gdpr_minimal'); ?>><?php esc_html_e('GDPR Minimal', 'king-addons'); ?></option> |
| 240 |
<option value="ccpa_minimal" <?php selected($options['template'], 'ccpa_minimal'); ?>><?php esc_html_e('CCPA Minimal', 'king-addons'); ?></option> |
| 241 |
<option value="custom" <?php selected($options['template'], 'custom'); ?>><?php esc_html_e('Custom', 'king-addons'); ?></option> |
| 242 |
</select> |
| 243 |
</div> |
| 244 |
</div> |
| 245 |
<div class="ka-row"> |
| 246 |
<div class="ka-row-label"><?php esc_html_e('Title', 'king-addons'); ?></div> |
| 247 |
<div class="ka-row-field"> |
| 248 |
<input type="text" name="content[title]" value="<?php echo esc_attr($options['content']['title']); ?>"> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
<div class="ka-row"> |
| 252 |
<div class="ka-row-label"><?php esc_html_e('Message', 'king-addons'); ?></div> |
| 253 |
<div class="ka-row-field"> |
| 254 |
<textarea name="content[message]" rows="3" style="max-width: 100%;"><?php echo esc_textarea($options['content']['message']); ?></textarea> |
| 255 |
</div> |
| 256 |
</div> |
| 257 |
<div class="ka-row"> |
| 258 |
<div class="ka-row-label"><?php esc_html_e('Privacy Link', 'king-addons'); ?></div> |
| 259 |
<div class="ka-row-field"> |
| 260 |
<div class="ka-grid-2"> |
| 261 |
<div> |
| 262 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('URL', 'king-addons'); ?></label> |
| 263 |
<input type="url" name="content[privacy_url]" value="<?php echo esc_attr($options['content']['privacy_url']); ?>"> |
| 264 |
</div> |
| 265 |
<div> |
| 266 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Label', 'king-addons'); ?></label> |
| 267 |
<input type="text" name="content[privacy_label]" value="<?php echo esc_attr($options['content']['privacy_label']); ?>"> |
| 268 |
</div> |
| 269 |
</div> |
| 270 |
</div> |
| 271 |
</div> |
| 272 |
<div class="ka-row"> |
| 273 |
<div class="ka-row-label"><?php esc_html_e('Cookie Policy', 'king-addons'); ?></div> |
| 274 |
<div class="ka-row-field"> |
| 275 |
<div class="ka-grid-2"> |
| 276 |
<div> |
| 277 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('URL', 'king-addons'); ?></label> |
| 278 |
<input type="url" name="content[cookie_url]" value="<?php echo esc_attr($options['content']['cookie_url']); ?>"> |
| 279 |
</div> |
| 280 |
<div> |
| 281 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Label', 'king-addons'); ?></label> |
| 282 |
<input type="text" name="content[cookie_label]" value="<?php echo esc_attr($options['content']['cookie_label']); ?>"> |
| 283 |
</div> |
| 284 |
</div> |
| 285 |
</div> |
| 286 |
</div> |
| 287 |
<div class="ka-row"> |
| 288 |
<div class="ka-row-label"><?php esc_html_e('Button Text', 'king-addons'); ?></div> |
| 289 |
<div class="ka-row-field"> |
| 290 |
<div class="ka-grid-2"> |
| 291 |
<div> |
| 292 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Accept', 'king-addons'); ?></label> |
| 293 |
<input type="text" name="buttons[accept]" value="<?php echo esc_attr($options['buttons']['accept']); ?>"> |
| 294 |
</div> |
| 295 |
<div> |
| 296 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Reject', 'king-addons'); ?></label> |
| 297 |
<input type="text" name="buttons[reject]" value="<?php echo esc_attr($options['buttons']['reject']); ?>"> |
| 298 |
</div> |
| 299 |
<div> |
| 300 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Settings', 'king-addons'); ?></label> |
| 301 |
<input type="text" name="buttons[settings]" value="<?php echo esc_attr($options['buttons']['settings']); ?>"> |
| 302 |
</div> |
| 303 |
<div> |
| 304 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php esc_html_e('Save', 'king-addons'); ?></label> |
| 305 |
<input type="text" name="buttons[save]" value="<?php echo esc_attr($options['buttons']['save']); ?>"> |
| 306 |
</div> |
| 307 |
</div> |
| 308 |
</div> |
| 309 |
</div> |
| 310 |
</div> |
| 311 |
</div> |
| 312 |
</div> |
| 313 |
|
| 314 |
<!-- Categories Tab --> |
| 315 |
<div class="ka-tab-content" data-tab="categories"> |
| 316 |
<div class="ka-card"> |
| 317 |
<div class="ka-card-header"> |
| 318 |
<span class="dashicons dashicons-category"></span> |
| 319 |
<h2><?php esc_html_e('Cookie Categories', 'king-addons'); ?></h2> |
| 320 |
</div> |
| 321 |
<div class="ka-card-body"> |
| 322 |
<p class="ka-row-desc" style="margin: 0 0 20px;"><?php esc_html_e('Define consent categories. "Necessary" is always required.', 'king-addons'); ?></p> |
| 323 |
<table class="ka-table"> |
| 324 |
<thead> |
| 325 |
<tr> |
| 326 |
<th style="width: 15%;"><?php esc_html_e('Key', 'king-addons'); ?></th> |
| 327 |
<th style="width: 20%;"><?php esc_html_e('Label', 'king-addons'); ?></th> |
| 328 |
<th><?php esc_html_e('Description', 'king-addons'); ?></th> |
| 329 |
<th style="width: 15%;"><?php esc_html_e('Default', 'king-addons'); ?></th> |
| 330 |
<th style="width: 10%;"><?php esc_html_e('Show', 'king-addons'); ?></th> |
| 331 |
</tr> |
| 332 |
</thead> |
| 333 |
<tbody> |
| 334 |
<?php foreach ($categories as $index => $category): ?> |
| 335 |
<tr> |
| 336 |
<td><input type="text" name="categories[<?php echo esc_attr($index); ?>][key]" value="<?php echo esc_attr($category['key']); ?>" <?php disabled($category['key'] === 'necessary'); ?>></td> |
| 337 |
<td><input type="text" name="categories[<?php echo esc_attr($index); ?>][label]" value="<?php echo esc_attr($category['label']); ?>"></td> |
| 338 |
<td><textarea name="categories[<?php echo esc_attr($index); ?>][description]" rows="2"><?php echo esc_textarea($category['description']); ?></textarea></td> |
| 339 |
<td> |
| 340 |
<select name="categories[<?php echo esc_attr($index); ?>][state]" <?php disabled($category['key'] === 'necessary'); ?>> |
| 341 |
<option value="required" <?php selected($category['state'], 'required'); ?>><?php esc_html_e('Required', 'king-addons'); ?></option> |
| 342 |
<option value="on" <?php selected($category['state'], 'on'); ?>><?php esc_html_e('On', 'king-addons'); ?></option> |
| 343 |
<option value="off" <?php selected($category['state'], 'off'); ?>><?php esc_html_e('Off', 'king-addons'); ?></option> |
| 344 |
</select> |
| 345 |
</td> |
| 346 |
<td style="text-align: center;"><input type="checkbox" name="categories[<?php echo esc_attr($index); ?>][display]" value="1" <?php checked($category['display']); ?>></td> |
| 347 |
</tr> |
| 348 |
<?php endforeach; ?> |
| 349 |
</tbody> |
| 350 |
</table> |
| 351 |
</div> |
| 352 |
</div> |
| 353 |
</div> |
| 354 |
|
| 355 |
<!-- Design Tab --> |
| 356 |
<div class="ka-tab-content" data-tab="design"> |
| 357 |
<div class="ka-card"> |
| 358 |
<div class="ka-card-header"> |
| 359 |
<span class="dashicons dashicons-art pink"></span> |
| 360 |
<h2><?php esc_html_e('Appearance', 'king-addons'); ?></h2> |
| 361 |
</div> |
| 362 |
<div class="ka-card-body"> |
| 363 |
<div class="ka-row"> |
| 364 |
<div class="ka-row-label"><?php esc_html_e('Layout', 'king-addons'); ?></div> |
| 365 |
<div class="ka-row-field"> |
| 366 |
<select name="design[layout]"> |
| 367 |
<option value="bottom-bar" <?php selected($options['design']['layout'], 'bottom-bar'); ?>><?php esc_html_e('Bottom bar', 'king-addons'); ?></option> |
| 368 |
<option value="top-bar" <?php selected($options['design']['layout'], 'top-bar'); ?>><?php esc_html_e('Top bar', 'king-addons'); ?></option> |
| 369 |
<option value="bottom-left" <?php selected($options['design']['layout'], 'bottom-left'); ?>><?php esc_html_e('Bottom left', 'king-addons'); ?></option> |
| 370 |
<option value="bottom-right" <?php selected($options['design']['layout'], 'bottom-right'); ?>><?php esc_html_e('Bottom right', 'king-addons'); ?></option> |
| 371 |
<option value="modal" <?php selected($options['design']['layout'], 'modal'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('Modal', 'king-addons'); ?><?php if (!$is_premium): ?> (Pro)<?php endif; ?></option> |
| 372 |
</select> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
<div class="ka-row"> |
| 376 |
<div class="ka-row-label"><?php esc_html_e('Preset', 'king-addons'); ?></div> |
| 377 |
<div class="ka-row-field"> |
| 378 |
<select name="design[preset]"> |
| 379 |
<option value="light" <?php selected($options['design']['preset'], 'light'); ?>><?php esc_html_e('Light', 'king-addons'); ?></option> |
| 380 |
<option value="dark" <?php selected($options['design']['preset'], 'dark'); ?>><?php esc_html_e('Dark', 'king-addons'); ?></option> |
| 381 |
<option value="minimal" <?php selected($options['design']['preset'], 'minimal'); ?>><?php esc_html_e('Minimal', 'king-addons'); ?></option> |
| 382 |
</select> |
| 383 |
</div> |
| 384 |
</div> |
| 385 |
<div class="ka-row"> |
| 386 |
<div class="ka-row-label"><?php esc_html_e('Colors', 'king-addons'); ?></div> |
| 387 |
<div class="ka-row-field"> |
| 388 |
<div class="ka-grid-2" style="gap: 16px;"> |
| 389 |
<?php foreach ($options['design']['colors'] as $color_key => $color_value): ?> |
| 390 |
<div> |
| 391 |
<label style="font-size: 12px; color: #86868b; display: block; margin-bottom: 6px;"><?php echo esc_html(ucwords(str_replace('_', ' ', $color_key))); ?></label> |
| 392 |
<input type="text" class="ka-color-picker" name="design[colors][<?php echo esc_attr($color_key); ?>]" value="<?php echo esc_attr($color_value); ?>"> |
| 393 |
</div> |
| 394 |
<?php endforeach; ?> |
| 395 |
</div> |
| 396 |
</div> |
| 397 |
</div> |
| 398 |
<div class="ka-row"> |
| 399 |
<div class="ka-row-label"><?php esc_html_e('Border Radius', 'king-addons'); ?></div> |
| 400 |
<div class="ka-row-field"> |
| 401 |
<input type="number" min="0" name="design[border_radius]" value="<?php echo esc_attr($options['design']['border_radius']); ?>" style="max-width: 100px;"> |
| 402 |
<span style="color: #86868b; margin-left: 8px;">px</span> |
| 403 |
</div> |
| 404 |
</div> |
| 405 |
<div class="ka-row"> |
| 406 |
<div class="ka-row-label"><?php esc_html_e('Shadow', 'king-addons'); ?></div> |
| 407 |
<div class="ka-row-field"> |
| 408 |
<label class="ka-toggle"> |
| 409 |
<input type="checkbox" name="design[shadow]" value="1" <?php checked($options['design']['shadow']); ?>> |
| 410 |
<span class="ka-toggle-slider"></span> |
| 411 |
<span class="ka-toggle-label"><?php esc_html_e('Enable shadow', 'king-addons'); ?></span> |
| 412 |
</label> |
| 413 |
</div> |
| 414 |
</div> |
| 415 |
<div class="ka-row"> |
| 416 |
<div class="ka-row-label"><?php esc_html_e('Animation', 'king-addons'); ?></div> |
| 417 |
<div class="ka-row-field"> |
| 418 |
<select name="design[animation]"> |
| 419 |
<option value="fade" <?php selected($options['design']['animation'], 'fade'); ?>><?php esc_html_e('Fade', 'king-addons'); ?></option> |
| 420 |
<option value="slide-up" <?php selected($options['design']['animation'], 'slide-up'); ?>><?php esc_html_e('Slide up', 'king-addons'); ?></option> |
| 421 |
<option value="slide-down" <?php selected($options['design']['animation'], 'slide-down'); ?>><?php esc_html_e('Slide down', 'king-addons'); ?></option> |
| 422 |
</select> |
| 423 |
</div> |
| 424 |
</div> |
| 425 |
</div> |
| 426 |
</div> |
| 427 |
</div> |
| 428 |
|
| 429 |
<!-- Scripts Tab --> |
| 430 |
<div class="ka-tab-content" data-tab="scripts"> |
| 431 |
<div class="ka-card"> |
| 432 |
<div class="ka-card-header"> |
| 433 |
<span class="dashicons dashicons-editor-code"></span> |
| 434 |
<h2><?php esc_html_e('Script Blocking', 'king-addons'); ?></h2> |
| 435 |
</div> |
| 436 |
<div class="ka-card-body"> |
| 437 |
<p class="ka-row-desc" style="margin: 0 0 12px;"><?php esc_html_e('Control scripts by WordPress script handle. Free: up to 3 rules.', 'king-addons'); ?></p> |
| 438 |
<p class="ka-row-desc" style="margin: 0 0 20px;"> |
| 439 |
<strong><?php esc_html_e('Mode:', 'king-addons'); ?></strong> |
| 440 |
<?php esc_html_e('“Block” keeps the script tag in place but prevents execution until consent. “Allow” removes the script URL to avoid downloading it at all until consent (recommended for third-party scripts).', 'king-addons'); ?> |
| 441 |
</p> |
| 442 |
<table class="ka-table"> |
| 443 |
<thead> |
| 444 |
<tr> |
| 445 |
<th><?php esc_html_e('Script Handle', 'king-addons'); ?></th> |
| 446 |
<th><?php esc_html_e('Category', 'king-addons'); ?></th> |
| 447 |
<th><?php esc_html_e('Mode', 'king-addons'); ?></th> |
| 448 |
</tr> |
| 449 |
</thead> |
| 450 |
<tbody> |
| 451 |
<?php $row_index = 0; ?> |
| 452 |
<?php foreach ($script_rules as $rule): ?> |
| 453 |
<?php if (!$is_premium && $row_index >= 3) { break; } ?> |
| 454 |
<tr> |
| 455 |
<td><input type="text" name="scripts[<?php echo esc_attr($row_index); ?>][handle]" value="<?php echo esc_attr($rule['handle']); ?>" placeholder="google-analytics"></td> |
| 456 |
<td> |
| 457 |
<select name="scripts[<?php echo esc_attr($row_index); ?>][category]"> |
| 458 |
<option value="analytics" <?php selected($rule['category'], 'analytics'); ?>><?php esc_html_e('Analytics', 'king-addons'); ?></option> |
| 459 |
<option value="marketing" <?php selected($rule['category'], 'marketing'); ?>><?php esc_html_e('Marketing', 'king-addons'); ?></option> |
| 460 |
<option value="other" <?php selected($rule['category'], 'other'); ?>><?php esc_html_e('Other', 'king-addons'); ?></option> |
| 461 |
</select> |
| 462 |
</td> |
| 463 |
<td> |
| 464 |
<select name="scripts[<?php echo esc_attr($row_index); ?>][mode]"> |
| 465 |
<option value="block" <?php selected($rule['mode'], 'block'); ?>><?php esc_html_e('Block until accepted', 'king-addons'); ?></option> |
| 466 |
<option value="allow" <?php selected($rule['mode'], 'allow'); ?>><?php esc_html_e('Load if accepted', 'king-addons'); ?></option> |
| 467 |
</select> |
| 468 |
</td> |
| 469 |
</tr> |
| 470 |
<?php $row_index++; ?> |
| 471 |
<?php endforeach; ?> |
| 472 |
</tbody> |
| 473 |
</table> |
| 474 |
</div> |
| 475 |
</div> |
| 476 |
</div> |
| 477 |
|
| 478 |
<!-- Behavior Tab --> |
| 479 |
<div class="ka-tab-content" data-tab="behavior"> |
| 480 |
<div class="ka-card"> |
| 481 |
<div class="ka-card-header"> |
| 482 |
<span class="dashicons dashicons-admin-page"></span> |
| 483 |
<h2><?php esc_html_e('Behavior Settings', 'king-addons'); ?></h2> |
| 484 |
</div> |
| 485 |
<div class="ka-card-body"> |
| 486 |
<div class="ka-row"> |
| 487 |
<div class="ka-row-label"><?php esc_html_e('Show On', 'king-addons'); ?></div> |
| 488 |
<div class="ka-row-field"> |
| 489 |
<select name="behavior[show_on]" <?php disabled(!$is_premium && $options['behavior']['show_on'] !== 'all'); ?>> |
| 490 |
<option value="all" <?php selected($options['behavior']['show_on'], 'all'); ?>><?php esc_html_e('All pages', 'king-addons'); ?></option> |
| 491 |
<option value="include" <?php selected($options['behavior']['show_on'], 'include'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('Only specific pages', 'king-addons'); ?><?php if (!$is_premium): ?> (Pro)<?php endif; ?></option> |
| 492 |
<option value="exclude" <?php selected($options['behavior']['show_on'], 'exclude'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('All except', 'king-addons'); ?><?php if (!$is_premium): ?> (Pro)<?php endif; ?></option> |
| 493 |
</select> |
| 494 |
<?php if ($is_premium): ?> |
| 495 |
<p class="ka-row-desc"><?php esc_html_e('Comma-separated page IDs', 'king-addons'); ?></p> |
| 496 |
<textarea name="behavior[include_pages]" rows="2" style="max-width: 300px; margin-top: 8px;"><?php echo esc_textarea($options['behavior']['include_pages']); ?></textarea> |
| 497 |
<textarea name="behavior[exclude_pages]" rows="2" style="max-width: 300px; margin-top: 4px;"><?php echo esc_textarea($options['behavior']['exclude_pages']); ?></textarea> |
| 498 |
<?php else: ?> |
| 499 |
<input type="hidden" name="behavior[include_pages]" value="<?php echo esc_attr($options['behavior']['include_pages']); ?>"> |
| 500 |
<input type="hidden" name="behavior[exclude_pages]" value="<?php echo esc_attr($options['behavior']['exclude_pages']); ?>"> |
| 501 |
<?php endif; ?> |
| 502 |
</div> |
| 503 |
</div> |
| 504 |
<div class="ka-row"> |
| 505 |
<div class="ka-row-label"><?php esc_html_e('Resurface', 'king-addons'); ?></div> |
| 506 |
<div class="ka-row-field"> |
| 507 |
<select name="behavior[resurface]"> |
| 508 |
<option value="version" <?php selected($options['behavior']['resurface'], 'version'); ?>><?php esc_html_e('On policy version change', 'king-addons'); ?></option> |
| 509 |
<option value="never" <?php selected($options['behavior']['resurface'], 'never'); ?>><?php esc_html_e('Never', 'king-addons'); ?></option> |
| 510 |
</select> |
| 511 |
</div> |
| 512 |
</div> |
| 513 |
<div class="ka-row"> |
| 514 |
<div class="ka-row-label"><?php esc_html_e('Consent Triggers', 'king-addons'); ?></div> |
| 515 |
<div class="ka-row-field"> |
| 516 |
<label class="ka-toggle" style="margin-bottom: 16px;"> |
| 517 |
<input type="checkbox" name="behavior[scroll_consent]" value="1" <?php checked($options['behavior']['scroll_consent']); ?> <?php disabled(!$is_premium); ?>> |
| 518 |
<span class="ka-toggle-slider"></span> |
| 519 |
<span class="ka-toggle-label"><?php esc_html_e('Scroll = consent', 'king-addons'); ?><?php if (!$is_premium): ?> <span class="ka-pro-badge">PRO</span><?php endif; ?></span> |
| 520 |
</label> |
| 521 |
<br> |
| 522 |
<label class="ka-toggle"> |
| 523 |
<input type="checkbox" name="behavior[click_consent]" value="1" <?php checked($options['behavior']['click_consent']); ?> <?php disabled(!$is_premium); ?>> |
| 524 |
<span class="ka-toggle-slider"></span> |
| 525 |
<span class="ka-toggle-label"><?php esc_html_e('Click outside = consent', 'king-addons'); ?><?php if (!$is_premium): ?> <span class="ka-pro-badge">PRO</span><?php endif; ?></span> |
| 526 |
</label> |
| 527 |
</div> |
| 528 |
</div> |
| 529 |
</div> |
| 530 |
</div> |
| 531 |
</div> |
| 532 |
|
| 533 |
<!-- Advanced Tab --> |
| 534 |
<div class="ka-tab-content" data-tab="advanced"> |
| 535 |
<div class="ka-card"> |
| 536 |
<div class="ka-card-header"> |
| 537 |
<span class="dashicons dashicons-admin-tools"></span> |
| 538 |
<h2><?php esc_html_e('Advanced Settings', 'king-addons'); ?></h2> |
| 539 |
</div> |
| 540 |
<div class="ka-card-body"> |
| 541 |
<div class="ka-row"> |
| 542 |
<div class="ka-row-label"><?php esc_html_e('Cookie Name', 'king-addons'); ?></div> |
| 543 |
<div class="ka-row-field"> |
| 544 |
<input type="text" name="advanced[cookie_name]" value="<?php echo esc_attr($options['advanced']['cookie_name']); ?>" style="max-width: 200px;"> |
| 545 |
</div> |
| 546 |
</div> |
| 547 |
<div class="ka-row"> |
| 548 |
<div class="ka-row-label"><?php esc_html_e('Cookie Path', 'king-addons'); ?></div> |
| 549 |
<div class="ka-row-field"> |
| 550 |
<input type="text" name="advanced[cookie_path]" value="<?php echo esc_attr($options['advanced']['cookie_path']); ?>" style="max-width: 100px;"> |
| 551 |
</div> |
| 552 |
</div> |
| 553 |
<div class="ka-row"> |
| 554 |
<div class="ka-row-label"><?php esc_html_e('SameSite', 'king-addons'); ?></div> |
| 555 |
<div class="ka-row-field"> |
| 556 |
<select name="advanced[same_site]"> |
| 557 |
<option value="Lax" <?php selected($options['advanced']['same_site'], 'Lax'); ?>>Lax</option> |
| 558 |
<option value="Strict" <?php selected($options['advanced']['same_site'], 'Strict'); ?>>Strict</option> |
| 559 |
<option value="None" <?php selected($options['advanced']['same_site'], 'None'); ?>>None</option> |
| 560 |
</select> |
| 561 |
<p class="ka-row-desc"><?php esc_html_e('Use “None” only when you need consent stored in cross-site contexts. Note: browsers require Secure when SameSite=None.', 'king-addons'); ?></p> |
| 562 |
</div> |
| 563 |
</div> |
| 564 |
<div class="ka-row"> |
| 565 |
<div class="ka-row-label"><?php esc_html_e('Secure Only', 'king-addons'); ?></div> |
| 566 |
<div class="ka-row-field"> |
| 567 |
<label class="ka-toggle"> |
| 568 |
<input type="checkbox" name="advanced[secure]" value="1" <?php checked($options['advanced']['secure']); ?>> |
| 569 |
<span class="ka-toggle-slider"></span> |
| 570 |
<span class="ka-toggle-label"><?php esc_html_e('HTTPS only', 'king-addons'); ?></span> |
| 571 |
</label> |
| 572 |
</div> |
| 573 |
</div> |
| 574 |
<div class="ka-row"> |
| 575 |
<div class="ka-row-label"><?php esc_html_e('Cookie Domain', 'king-addons'); ?></div> |
| 576 |
<div class="ka-row-field"> |
| 577 |
<input type="text" name="advanced[cookie_domain]" value="<?php echo esc_attr($options['advanced']['cookie_domain']); ?>" placeholder="example.com" style="max-width: 200px;"> |
| 578 |
</div> |
| 579 |
</div> |
| 580 |
<div class="ka-row"> |
| 581 |
<div class="ka-row-label"><?php esc_html_e('Storage', 'king-addons'); ?></div> |
| 582 |
<div class="ka-row-field"> |
| 583 |
<select name="advanced[storage]"> |
| 584 |
<option value="cookie" <?php selected($options['advanced']['storage'], 'cookie'); ?>><?php esc_html_e('Cookie', 'king-addons'); ?></option> |
| 585 |
<option value="local" <?php selected($options['advanced']['storage'], 'local'); ?> <?php disabled(!$is_premium); ?>><?php esc_html_e('Local Storage', 'king-addons'); ?><?php if (!$is_premium): ?> (Pro)<?php endif; ?></option> |
| 586 |
</select> |
| 587 |
</div> |
| 588 |
</div> |
| 589 |
<div class="ka-row"> |
| 590 |
<div class="ka-row-label"><?php esc_html_e('Data Attributes', 'king-addons'); ?></div> |
| 591 |
<div class="ka-row-field"> |
| 592 |
<label class="ka-toggle"> |
| 593 |
<input type="checkbox" name="data_attribute_support" value="1" <?php checked($options['data_attribute_support']); ?> <?php disabled(!$is_premium); ?>> |
| 594 |
<span class="ka-toggle-slider"></span> |
| 595 |
<span class="ka-toggle-label"><?php esc_html_e('Enable data-attribute activation', 'king-addons'); ?><?php if (!$is_premium): ?> <span class="ka-pro-badge">PRO</span><?php endif; ?></span> |
| 596 |
</label> |
| 597 |
<p class="ka-row-desc" style="margin-top: 10px;"> |
| 598 |
<?php esc_html_e('When enabled, you can delay loading embeds/assets until consent by putting the real URL into a data attribute, plus setting the consent category.', 'king-addons'); ?> |
| 599 |
</p> |
| 600 |
<p class="ka-row-desc" style="margin-top: 6px;"> |
| 601 |
<strong><?php esc_html_e('Supported attributes:', 'king-addons'); ?></strong> |
| 602 |
<?php echo esc_html('data-ka-cookie-src, data-ka-cookie-srcset, data-ka-cookie-href, data-ka-cookie-poster, data-ka-cookie-show'); ?> |
| 603 |
</p> |
| 604 |
<p class="ka-row-desc" style="margin-top: 6px;"> |
| 605 |
<strong><?php esc_html_e('Example:', 'king-addons'); ?></strong> |
| 606 |
<?php echo esc_html('<iframe data-ka-cookie-category="marketing" data-ka-cookie-src="https://example.com/embed" data-ka-cookie-show hidden></iframe>'); ?> |
| 607 |
</p> |
| 608 |
</div> |
| 609 |
</div> |
| 610 |
</div> |
| 611 |
</div> |
| 612 |
|
| 613 |
<?php if ($is_premium): ?> |
| 614 |
<div class="ka-card"> |
| 615 |
<div class="ka-card-header"> |
| 616 |
<span class="dashicons dashicons-migrate"></span> |
| 617 |
<h2><?php esc_html_e('Import / Export', 'king-addons'); ?></h2> |
| 618 |
</div> |
| 619 |
<div class="ka-card-body"> |
| 620 |
<div class="ka-row"> |
| 621 |
<div class="ka-row-label"><?php esc_html_e('Export', 'king-addons'); ?></div> |
| 622 |
<div class="ka-row-field"> |
| 623 |
<button type="submit" class="ka-btn ka-btn-secondary ka-btn-sm" form="king-addons-cookie-consent-export"><?php esc_html_e('Download JSON', 'king-addons'); ?></button> |
| 624 |
</div> |
| 625 |
</div> |
| 626 |
<div class="ka-row"> |
| 627 |
<div class="ka-row-label"><?php esc_html_e('Import', 'king-addons'); ?></div> |
| 628 |
<div class="ka-row-field"> |
| 629 |
<input type="file" name="king_addons_cookie_import" form="king-addons-cookie-consent-import" accept="application/json" style="margin-bottom: 12px;"> |
| 630 |
<br> |
| 631 |
<button type="submit" class="ka-btn ka-btn-secondary ka-btn-sm" form="king-addons-cookie-consent-import"><?php esc_html_e('Import JSON', 'king-addons'); ?></button> |
| 632 |
</div> |
| 633 |
</div> |
| 634 |
</div> |
| 635 |
</div> |
| 636 |
<?php endif; ?> |
| 637 |
</div> |
| 638 |
|
| 639 |
<!-- Logs Tab --> |
| 640 |
<div class="ka-tab-content" data-tab="logs"> |
| 641 |
<?php if (!$is_premium): ?> |
| 642 |
<div class="ka-pro-notice"> |
| 643 |
<h2><?php esc_html_e('Consent Analytics', 'king-addons'); ?></h2> |
| 644 |
<p><?php esc_html_e('Upgrade to Pro to track consent rates and manage logs.', 'king-addons'); ?></p> |
| 645 |
<a href="https://kingaddons.com/pricing/" target="_blank" class="ka-btn ka-btn-pink"><?php esc_html_e('Upgrade Now', 'king-addons'); ?></a> |
| 646 |
</div> |
| 647 |
<?php else: ?> |
| 648 |
<div class="ka-card"> |
| 649 |
<div class="ka-card-header"> |
| 650 |
<span class="dashicons dashicons-chart-bar pink"></span> |
| 651 |
<h2><?php esc_html_e('Consent Analytics', 'king-addons'); ?></h2> |
| 652 |
</div> |
| 653 |
<div class="ka-card-body"> |
| 654 |
<div class="ka-row"> |
| 655 |
<div class="ka-row-label"><?php esc_html_e('Enable Logs', 'king-addons'); ?></div> |
| 656 |
<div class="ka-row-field"> |
| 657 |
<label class="ka-toggle"> |
| 658 |
<input type="checkbox" name="logs[enabled]" value="1" <?php checked($options['logs']['enabled']); ?>> |
| 659 |
<span class="ka-toggle-slider"></span> |
| 660 |
<span class="ka-toggle-label"><?php esc_html_e('Record consent events', 'king-addons'); ?></span> |
| 661 |
</label> |
| 662 |
</div> |
| 663 |
</div> |
| 664 |
<div class="ka-row"> |
| 665 |
<div class="ka-row-label"><?php esc_html_e('Retention', 'king-addons'); ?></div> |
| 666 |
<div class="ka-row-field"> |
| 667 |
<input type="number" name="logs[retention]" value="<?php echo esc_attr($options['logs']['retention']); ?>" min="30" style="max-width: 100px;"> |
| 668 |
<span style="color: #86868b; margin-left: 8px;"><?php esc_html_e('days', 'king-addons'); ?></span> |
| 669 |
</div> |
| 670 |
</div> |
| 671 |
|
| 672 |
<?php |
| 673 |
global $wpdb; |
| 674 |
$table = $wpdb->prefix . \King_Addons\Cookie_Consent::LOG_TABLE; |
| 675 |
$totals = ['accept' => 0, 'reject' => 0, 'custom' => 0]; |
| 676 |
if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table)) === $table) { |
| 677 |
$rows = $wpdb->get_results("SELECT action, COUNT(*) as total FROM {$table} GROUP BY action", ARRAY_A); |
| 678 |
foreach ((array) $rows as $row) { |
| 679 |
$totals[$row['action']] = (int) $row['total']; |
| 680 |
} |
| 681 |
} |
| 682 |
?> |
| 683 |
|
| 684 |
<div class="ka-stats-grid" style="margin-top: 20px;"> |
| 685 |
<div class="ka-stat-card"> |
| 686 |
<div class="ka-stat-label"><?php esc_html_e('Accepted', 'king-addons'); ?></div> |
| 687 |
<div class="ka-stat-value good"><?php echo esc_html($totals['accept']); ?></div> |
| 688 |
</div> |
| 689 |
<div class="ka-stat-card"> |
| 690 |
<div class="ka-stat-label"><?php esc_html_e('Rejected', 'king-addons'); ?></div> |
| 691 |
<div class="ka-stat-value"><?php echo esc_html($totals['reject']); ?></div> |
| 692 |
</div> |
| 693 |
<div class="ka-stat-card"> |
| 694 |
<div class="ka-stat-label"><?php esc_html_e('Customized', 'king-addons'); ?></div> |
| 695 |
<div class="ka-stat-value"><?php echo esc_html($totals['custom']); ?></div> |
| 696 |
</div> |
| 697 |
</div> |
| 698 |
|
| 699 |
<div class="ka-row"> |
| 700 |
<div class="ka-row-label"><?php esc_html_e('Clear Logs', 'king-addons'); ?></div> |
| 701 |
<div class="ka-row-field"> |
| 702 |
<div style="display: flex; gap: 12px; align-items: center;"> |
| 703 |
<select name="retention" form="king-addons-cookie-consent-clear-logs" style="max-width: 200px;"> |
| 704 |
<option value="30"><?php esc_html_e('Older than 30 days', 'king-addons'); ?></option> |
| 705 |
<option value="90"><?php esc_html_e('Older than 90 days', 'king-addons'); ?></option> |
| 706 |
<option value="365"><?php esc_html_e('Older than 1 year', 'king-addons'); ?></option> |
| 707 |
<option value="all"><?php esc_html_e('All logs', 'king-addons'); ?></option> |
| 708 |
</select> |
| 709 |
<button type="submit" class="ka-btn ka-btn-secondary ka-btn-sm" form="king-addons-cookie-consent-clear-logs"><?php esc_html_e('Clear', 'king-addons'); ?></button> |
| 710 |
</div> |
| 711 |
</div> |
| 712 |
</div> |
| 713 |
</div> |
| 714 |
</div> |
| 715 |
<?php endif; ?> |
| 716 |
</div> |
| 717 |
|
| 718 |
<!-- Submit --> |
| 719 |
<div class="ka-card"> |
| 720 |
<div class="ka-submit"> |
| 721 |
<button type="submit" class="ka-btn ka-btn-primary"><?php esc_html_e('Save Settings', 'king-addons'); ?></button> |
| 722 |
</div> |
| 723 |
</div> |
| 724 |
</form> |
| 725 |
|
| 726 |
<?php if ($is_premium): ?> |
| 727 |
<form id="king-addons-cookie-consent-export" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" style="display: none;"> |
| 728 |
<?php wp_nonce_field('king_addons_cookie_consent_export'); ?> |
| 729 |
<input type="hidden" name="action" value="king_addons_cookie_consent_export"> |
| 730 |
</form> |
| 731 |
<form id="king-addons-cookie-consent-import" method="post" enctype="multipart/form-data" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" style="display: none;"> |
| 732 |
<?php wp_nonce_field('king_addons_cookie_consent_import'); ?> |
| 733 |
<input type="hidden" name="action" value="king_addons_cookie_consent_import"> |
| 734 |
</form> |
| 735 |
<form id="king-addons-cookie-consent-clear-logs" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" style="display: none;"> |
| 736 |
<?php wp_nonce_field('king_addons_cookie_consent_clear_logs'); ?> |
| 737 |
<input type="hidden" name="action" value="king_addons_cookie_consent_clear_logs"> |
| 738 |
</form> |
| 739 |
<?php endif; ?> |
| 740 |
</div> |
| 741 |
|
| 742 |
<script> |
| 743 |
(function($) { |
| 744 |
'use strict'; |
| 745 |
|
| 746 |
// Tab navigation |
| 747 |
const tabs = document.querySelectorAll('.ka-tab'); |
| 748 |
const contents = document.querySelectorAll('.ka-tab-content'); |
| 749 |
|
| 750 |
tabs.forEach(tab => { |
| 751 |
tab.addEventListener('click', function(e) { |
| 752 |
e.preventDefault(); |
| 753 |
const target = this.dataset.tab; |
| 754 |
tabs.forEach(t => t.classList.remove('active')); |
| 755 |
contents.forEach(c => c.classList.remove('active')); |
| 756 |
this.classList.add('active'); |
| 757 |
document.querySelector(`.ka-tab-content[data-tab="${target}"]`).classList.add('active'); |
| 758 |
}); |
| 759 |
}); |
| 760 |
|
| 761 |
// Color pickers |
| 762 |
$(document).ready(function() { |
| 763 |
if ($.fn.wpColorPicker) { |
| 764 |
$('.ka-color-picker').wpColorPicker(); |
| 765 |
} |
| 766 |
}); |
| 767 |
})(jQuery); |
| 768 |
|
| 769 |
// Theme segmented control (dashboard-style) |
| 770 |
(function() { |
| 771 |
const ajaxUrl = '<?php echo esc_url(admin_url('admin-ajax.php')); ?>'; |
| 772 |
const nonce = '<?php echo esc_js(wp_create_nonce('king_addons_dashboard_ui')); ?>'; |
| 773 |
const segment = document.getElementById('ka-v3-theme-segment'); |
| 774 |
const mql = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null; |
| 775 |
let mode = (segment && segment.getAttribute('data-active') ? segment.getAttribute('data-active') : 'dark').toString(); |
| 776 |
let mqlHandler = null; |
| 777 |
|
| 778 |
function saveUISetting(key, value) { |
| 779 |
const body = new URLSearchParams(); |
| 780 |
body.set('action', 'king_addons_save_dashboard_ui'); |
| 781 |
body.set('nonce', nonce); |
| 782 |
body.set('key', key); |
| 783 |
body.set('value', value); |
| 784 |
fetch(ajaxUrl, { |
| 785 |
method: 'POST', |
| 786 |
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, |
| 787 |
body: body.toString() |
| 788 |
}); |
| 789 |
} |
| 790 |
|
| 791 |
function updateSegment(activeMode) { |
| 792 |
if (!segment) { |
| 793 |
return; |
| 794 |
} |
| 795 |
segment.setAttribute('data-active', activeMode); |
| 796 |
segment.querySelectorAll('.ka-v3-segmented-btn').forEach((btn) => { |
| 797 |
const theme = btn.getAttribute('data-theme'); |
| 798 |
btn.setAttribute('aria-pressed', theme === activeMode ? 'true' : 'false'); |
| 799 |
}); |
| 800 |
} |
| 801 |
|
| 802 |
function applyTheme(isDark) { |
| 803 |
document.body.classList.toggle('ka-v3-dark', isDark); |
| 804 |
document.documentElement.classList.toggle('ka-v3-dark', isDark); |
| 805 |
} |
| 806 |
|
| 807 |
function setThemeMode(nextMode, save) { |
| 808 |
mode = nextMode; |
| 809 |
updateSegment(nextMode); |
| 810 |
|
| 811 |
if (mqlHandler && mql) { |
| 812 |
if (mql.removeEventListener) { |
| 813 |
mql.removeEventListener('change', mqlHandler); |
| 814 |
} else if (mql.removeListener) { |
| 815 |
mql.removeListener(mqlHandler); |
| 816 |
} |
| 817 |
mqlHandler = null; |
| 818 |
} |
| 819 |
|
| 820 |
if (nextMode === 'auto') { |
| 821 |
applyTheme(!!(mql && mql.matches)); |
| 822 |
mqlHandler = (e) => { |
| 823 |
if (mode !== 'auto') { |
| 824 |
return; |
| 825 |
} |
| 826 |
applyTheme(!!e.matches); |
| 827 |
}; |
| 828 |
if (mql) { |
| 829 |
if (mql.addEventListener) { |
| 830 |
mql.addEventListener('change', mqlHandler); |
| 831 |
} else if (mql.addListener) { |
| 832 |
mql.addListener(mqlHandler); |
| 833 |
} |
| 834 |
} |
| 835 |
} else { |
| 836 |
applyTheme(nextMode === 'dark'); |
| 837 |
} |
| 838 |
|
| 839 |
if (save) { |
| 840 |
saveUISetting('theme_mode', nextMode); |
| 841 |
} |
| 842 |
} |
| 843 |
|
| 844 |
window.kaV3ToggleDark = function() { |
| 845 |
const isDark = document.body.classList.contains('ka-v3-dark'); |
| 846 |
setThemeMode(isDark ? 'light' : 'dark', true); |
| 847 |
}; |
| 848 |
|
| 849 |
if (segment) { |
| 850 |
segment.addEventListener('click', function(e) { |
| 851 |
const btn = e.target.closest('.ka-v3-segmented-btn'); |
| 852 |
if (!btn) return; |
| 853 |
e.preventDefault(); |
| 854 |
setThemeMode((btn.getAttribute('data-theme') || 'dark').toString(), true); |
| 855 |
}); |
| 856 |
} |
| 857 |
|
| 858 |
if (segment) { |
| 859 |
setThemeMode(mode, false); |
| 860 |
} |
| 861 |
})(); |
| 862 |
</script> |
| 863 |
|