← All changes
|
includes/extensions/Age_Gate/templates/admin-page.php
+50
-1
51.1.78
→
51.1.87
View file →
| @@ -48,12 +48,36 @@ | ||
| 48 | 48 | 'exclude_ids' => [], |
| 49 | 49 | 'mode' => 'global', |
| 50 | 50 | 'cpt_scope' => [], |
| 51 | 51 | 'archives' => 0, |
| 52 | + 'woo' => [ | |
| 53 | + 'enabled' => 0, | |
| 54 | + 'apply_to' => 'product', | |
| 55 | + 'categories' => [], | |
| 56 | + ], | |
| 52 | 57 | ]); |
| 53 | 58 | $options['display']['exclude_ids'] = array_map('intval', (array) $options['display']['exclude_ids']); |
| 54 | 59 | $options['display']['cpt_scope'] = array_values(array_map('strval', (array) $options['display']['cpt_scope'])); |
| 60 | +$options['display']['woo'] = wp_parse_args($options['display']['woo'] ?? [], [ | |
| 61 | + 'enabled' => 0, | |
| 62 | + 'apply_to' => 'product', | |
| 63 | + 'categories' => [], | |
| 64 | +]); | |
| 65 | +$options['display']['woo']['categories'] = array_map('intval', (array) $options['display']['woo']['categories']); | |
| 55 | 66 | |
| 67 | +$product_cats = []; | |
| 68 | +if (taxonomy_exists('product_cat')) { | |
| 69 | + $woo_terms = get_terms([ | |
| 70 | + 'taxonomy' => 'product_cat', | |
| 71 | + 'hide_empty' => false, | |
| 72 | + ]); | |
| 73 | + if (!is_wp_error($woo_terms)) { | |
| 74 | + foreach ($woo_terms as $woo_term) { | |
| 75 | + $product_cats[(int) $woo_term->term_id] = $woo_term->name; | |
| 76 | + } | |
| 77 | + } | |
| 78 | +} | |
| 79 | + | |
| 56 | 80 | $options['design'] = wp_parse_args($options['design'] ?? [], [ |
| 57 | 81 | 'template' => 'center-card', |
| 58 | 82 | 'overlay_color' => '#000000', |
| 59 | 83 | 'overlay_opacity' => 0.6, |
| @@ -132,9 +156,9 @@ | ||
| 132 | 156 | // Theme mode is per-user |
| 133 | 157 | $theme_mode = get_user_meta(get_current_user_id(), 'king_addons_theme_mode', true); |
| 134 | 158 | $allowed_theme_modes = ['dark', 'light', 'auto']; |
| 135 | 159 | if (!in_array($theme_mode, $allowed_theme_modes, true)) { |
| 136 | - $theme_mode = 'dark'; | |
| 160 | + $theme_mode = 'auto'; | |
| 137 | 161 | } |
| 138 | 162 | ?> |
| 139 | 163 | <script> |
| 140 | 164 | (function() { |
| @@ -328,8 +352,33 @@ | ||
| 328 | 352 | <input type="checkbox" name="king_addons_age_gate_options[display][archives]" value="1" <?php checked(!empty($options['display']['archives'])); ?>> |
| 329 | 353 | <span class="ka-toggle-slider"></span> |
| 330 | 354 | <span class="ka-toggle-label"><?php esc_html_e('Show on archives', 'king-addons'); ?></span> |
| 331 | 355 | </label> |
| 356 | + </div> | |
| 357 | + </div> | |
| 358 | + <div class="ka-row"> | |
| 359 | + <div class="ka-row-label"><?php esc_html_e('WooCommerce', 'king-addons'); ?></div> | |
| 360 | + <div class="ka-row-field"> | |
| 361 | + <label class="ka-toggle"> | |
| 362 | + <input type="checkbox" name="king_addons_age_gate_options[display][woo][enabled]" value="1" <?php checked(!empty($options['display']['woo']['enabled'])); ?>> | |
| 363 | + <span class="ka-toggle-slider"></span> | |
| 364 | + <span class="ka-toggle-label"><?php esc_html_e('Show on WooCommerce', 'king-addons'); ?></span> | |
| 365 | + </label> | |
| 366 | + <select name="king_addons_age_gate_options[display][woo][apply_to]" style="margin-top: 10px; max-width: 100%;"> | |
| 367 | + <option value="product" <?php selected($options['display']['woo']['apply_to'], 'product'); ?>><?php esc_html_e('Single products', 'king-addons'); ?></option> | |
| 368 | + <option value="category" <?php selected($options['display']['woo']['apply_to'], 'category'); ?>><?php esc_html_e('Product categories', 'king-addons'); ?></option> | |
| 369 | + <option value="shop" <?php selected($options['display']['woo']['apply_to'], 'shop'); ?>><?php esc_html_e('Shop page', 'king-addons'); ?></option> | |
| 370 | + </select> | |
| 371 | + <?php if ($product_cats): ?> | |
| 372 | + <select name="king_addons_age_gate_options[display][woo][categories][]" multiple size="4" style="margin-top: 10px; max-width: 100%; min-height: 100px;"> | |
| 373 | + <?php foreach ($product_cats as $cat_id => $cat_name): ?> | |
| 374 | + <option value="<?php echo esc_attr((string) $cat_id); ?>" <?php selected(in_array((int) $cat_id, $options['display']['woo']['categories'], true)); ?>> | |
| 375 | + <?php echo esc_html($cat_name); ?> | |
| 376 | + </option> | |
| 377 | + <?php endforeach; ?> | |
| 378 | + </select> | |
| 379 | + <p class="ka-row-desc"><?php esc_html_e('Leave categories empty to match every product or every product category. The shop page ignores this list.', 'king-addons'); ?></p> | |
| 380 | + <?php endif; ?> | |
| 332 | 381 | </div> |
| 333 | 382 | </div> |
| 334 | 383 | <?php endif; ?> |
| 335 | 384 | </div> |