| 1 |
<?php |
| 2 |
/** |
| 3 |
* Custom Code Manager - Editor Page Template |
| 4 |
* |
| 5 |
* @package King_Addons |
| 6 |
*/ |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
use King_Addons\Custom_Code_Manager; |
| 11 |
|
| 12 |
/** @var array|null $snippet */ |
| 13 |
/** @var bool $is_new */ |
| 14 |
/** @var bool $has_pro */ |
| 15 |
/** @var array $defaults */ |
| 16 |
/** @var array $config */ |
| 17 |
|
| 18 |
$type_icons = [ |
| 19 |
'css' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"><path d="M4 4h16v16H4z"/><path d="M9 9h6v6H9z"/></svg>', |
| 20 |
'js' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"><path d="M12 2v20M2 12h20"/></svg>', |
| 21 |
'html' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>', |
| 22 |
]; |
| 23 |
?> |
| 24 |
<script> |
| 25 |
window.kngCCInitialConfig = <?php echo wp_json_encode($config); ?>; |
| 26 |
</script> |
| 27 |
|
| 28 |
<div class="kng-cc-admin kng-cc-editor-page"> |
| 29 |
<form id="kng-cc-editor-form" class="kng-cc-editor-form" autocomplete="off"> |
| 30 |
<!-- Header --> |
| 31 |
<header class="kng-cc-header kng-cc-header--sticky"> |
| 32 |
<div class="kng-cc-header-left"> |
| 33 |
<a href="<?php echo esc_url(admin_url('admin.php?page=king-addons-custom-code')); ?>" class="kng-cc-back-btn"> |
| 34 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"> |
| 35 |
<line x1="19" y1="12" x2="5" y2="12"/> |
| 36 |
<polyline points="12 19 5 12 12 5"/> |
| 37 |
</svg> |
| 38 |
<?php esc_html_e('Back to snippets', 'king-addons'); ?> |
| 39 |
</a> |
| 40 |
<h1 class="kng-cc-title"> |
| 41 |
<?php echo $is_new ? esc_html__('New Snippet', 'king-addons') : esc_html__('Edit Snippet', 'king-addons'); ?> |
| 42 |
</h1> |
| 43 |
</div> |
| 44 |
<div class="kng-cc-header-right"> |
| 45 |
<div class="ka-v3-segmented" id="ka-v3-theme-segment" role="radiogroup" aria-label="<?php echo esc_attr(esc_html__('Theme', 'king-addons')); ?>" data-active="<?php echo esc_attr($theme_mode); ?>"> |
| 46 |
<span class="ka-v3-segmented-indicator" aria-hidden="true"></span> |
| 47 |
<button type="button" class="ka-v3-segmented-btn" data-theme="light" aria-pressed="<?php echo $theme_mode === 'light' ? 'true' : 'false'; ?>"> |
| 48 |
<span class="ka-v3-segmented-icon" aria-hidden="true">☀︎</span> |
| 49 |
<?php esc_html_e('Light', 'king-addons'); ?> |
| 50 |
</button> |
| 51 |
<button type="button" class="ka-v3-segmented-btn" data-theme="dark" aria-pressed="<?php echo $theme_mode === 'dark' ? 'true' : 'false'; ?>"> |
| 52 |
<span class="ka-v3-segmented-icon" aria-hidden="true">☾</span> |
| 53 |
<?php esc_html_e('Dark', 'king-addons'); ?> |
| 54 |
</button> |
| 55 |
<button type="button" class="ka-v3-segmented-btn" data-theme="auto" aria-pressed="<?php echo $theme_mode === 'auto' ? 'true' : 'false'; ?>"> |
| 56 |
<span class="ka-v3-segmented-icon" aria-hidden="true">◐</span> |
| 57 |
<?php esc_html_e('Auto', 'king-addons'); ?> |
| 58 |
</button> |
| 59 |
</div> |
| 60 |
<div class="kng-cc-status-wrap"> |
| 61 |
<label class="kng-v3-toggle-wrap"> |
| 62 |
<input type="checkbox" name="status" id="kng-cc-status" <?php checked($config['status'], 'enabled'); ?> /> |
| 63 |
<span class="kng-v3-toggle-slider"></span> |
| 64 |
</label> |
| 65 |
<span class="kng-cc-status-label" id="kng-cc-status-label"> |
| 66 |
<?php echo $config['status'] === 'enabled' ? esc_html__('Enabled', 'king-addons') : esc_html__('Disabled', 'king-addons'); ?> |
| 67 |
</span> |
| 68 |
</div> |
| 69 |
<button type="submit" class="kng-v3-btn kng-v3-btn--primary" id="kng-cc-save-btn"> |
| 70 |
<span class="kng-cc-btn-icons"> |
| 71 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18" class="kng-cc-save-icon kng-cc-btn-icon"> |
| 72 |
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/> |
| 73 |
<polyline points="17 21 17 13 7 13 7 21"/> |
| 74 |
<polyline points="7 3 7 8 15 8"/> |
| 75 |
</svg> |
| 76 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18" class="kng-cc-spinner kng-cc-btn-icon"> |
| 77 |
<circle cx="12" cy="12" r="10" stroke-dasharray="32" stroke-dashoffset="32"> |
| 78 |
<animate attributeName="stroke-dashoffset" values="32;0;32" dur="1s" repeatCount="indefinite"/> |
| 79 |
</circle> |
| 80 |
</svg> |
| 81 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" width="18" height="18" class="kng-cc-check-icon kng-cc-btn-icon"> |
| 82 |
<polyline points="20 6 9 17 4 12"/> |
| 83 |
</svg> |
| 84 |
</span> |
| 85 |
<span class="kng-cc-save-text"><?php esc_html_e('Save Snippet', 'king-addons'); ?></span> |
| 86 |
</button> |
| 87 |
</div> |
| 88 |
</header> |
| 89 |
|
| 90 |
<input type="hidden" name="id" id="kng-cc-id" value="<?php echo esc_attr($config['id']); ?>" /> |
| 91 |
|
| 92 |
<div class="kng-cc-editor-layout"> |
| 93 |
<!-- Main Content --> |
| 94 |
<div class="kng-cc-editor-main"> |
| 95 |
<!-- Title --> |
| 96 |
<div class="kng-cc-editor-section kng-cc-title-section"> |
| 97 |
<input type="text" |
| 98 |
name="title" |
| 99 |
id="kng-cc-title" |
| 100 |
class="kng-cc-title-input" |
| 101 |
placeholder="<?php esc_attr_e('Snippet name...', 'king-addons'); ?>" |
| 102 |
value="<?php echo esc_attr($config['title']); ?>" |
| 103 |
required /> |
| 104 |
</div> |
| 105 |
|
| 106 |
<!-- Code Editor --> |
| 107 |
<div class="kng-cc-editor-section kng-cc-code-section"> |
| 108 |
<div class="kng-cc-code-header"> |
| 109 |
<div class="kng-cc-type-tabs" role="tablist"> |
| 110 |
<button type="button" |
| 111 |
class="kng-cc-type-tab <?php echo $config['type'] === 'css' ? 'is-active' : ''; ?>" |
| 112 |
data-type="css" |
| 113 |
role="tab" |
| 114 |
aria-selected="<?php echo $config['type'] === 'css' ? 'true' : 'false'; ?>"> |
| 115 |
<?php echo $type_icons['css']; // phpcs:ignore ?> |
| 116 |
<span>CSS</span> |
| 117 |
</button> |
| 118 |
<button type="button" |
| 119 |
class="kng-cc-type-tab <?php echo $config['type'] === 'js' ? 'is-active' : ''; ?>" |
| 120 |
data-type="js" |
| 121 |
role="tab" |
| 122 |
aria-selected="<?php echo $config['type'] === 'js' ? 'true' : 'false'; ?>"> |
| 123 |
<?php echo $type_icons['js']; // phpcs:ignore ?> |
| 124 |
<span>JavaScript</span> |
| 125 |
</button> |
| 126 |
<button type="button" |
| 127 |
class="kng-cc-type-tab <?php echo $config['type'] === 'html' ? 'is-active' : ''; ?> <?php echo !$has_pro ? 'is-pro' : ''; ?>" |
| 128 |
data-type="html" |
| 129 |
role="tab" |
| 130 |
aria-selected="<?php echo $config['type'] === 'html' ? 'true' : 'false'; ?>" |
| 131 |
<?php echo !$has_pro ? 'disabled' : ''; ?>> |
| 132 |
<?php echo $type_icons['html']; // phpcs:ignore ?> |
| 133 |
<span>HTML</span> |
| 134 |
<?php if (!$has_pro): ?> |
| 135 |
<span class="kng-cc-pro-badge">PRO</span> |
| 136 |
<?php endif; ?> |
| 137 |
</button> |
| 138 |
</div> |
| 139 |
<div class="kng-cc-code-actions"> |
| 140 |
<button type="button" class="kng-cc-code-action" id="kng-cc-fullscreen" title="<?php esc_attr_e('Fullscreen', 'king-addons'); ?>"> |
| 141 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"> |
| 142 |
<path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/> |
| 143 |
</svg> |
| 144 |
</button> |
| 145 |
</div> |
| 146 |
</div> |
| 147 |
<input type="hidden" name="type" id="kng-cc-type" value="<?php echo esc_attr($config['type']); ?>" /> |
| 148 |
<div class="kng-cc-code-editor-wrap" id="kng-cc-code-wrap"> |
| 149 |
<textarea name="code" id="kng-cc-code" class="kng-cc-code-textarea"><?php echo esc_textarea($config['code']); ?></textarea> |
| 150 |
</div> |
| 151 |
</div> |
| 152 |
|
| 153 |
<!-- Notes --> |
| 154 |
<div class="kng-cc-editor-section kng-cc-notes-section"> |
| 155 |
<div class="kng-cc-section-header" data-collapsible="notes"> |
| 156 |
<h3 class="kng-cc-section-title"> |
| 157 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18"> |
| 158 |
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/> |
| 159 |
<polyline points="14 2 14 8 20 8"/> |
| 160 |
<line x1="16" y1="13" x2="8" y2="13"/> |
| 161 |
<line x1="16" y1="17" x2="8" y2="17"/> |
| 162 |
</svg> |
| 163 |
<?php esc_html_e('Notes', 'king-addons'); ?> |
| 164 |
</h3> |
| 165 |
<svg class="kng-cc-collapse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18"> |
| 166 |
<polyline points="6 9 12 15 18 9"/> |
| 167 |
</svg> |
| 168 |
</div> |
| 169 |
<div class="kng-cc-section-content" id="kng-cc-notes-content"> |
| 170 |
<textarea name="notes" id="kng-cc-notes" class="kng-v3-textarea" rows="3" placeholder="<?php esc_attr_e('Add notes about this snippet...', 'king-addons'); ?>"><?php echo esc_textarea($config['notes']); ?></textarea> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
</div> |
| 174 |
|
| 175 |
<!-- Sidebar --> |
| 176 |
<div class="kng-cc-editor-sidebar"> |
| 177 |
<!-- Injection Settings --> |
| 178 |
<div class="kng-cc-sidebar-section"> |
| 179 |
<h3 class="kng-cc-sidebar-title"> |
| 180 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18"> |
| 181 |
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/> |
| 182 |
<polyline points="17 8 12 3 7 8"/> |
| 183 |
<line x1="12" y1="3" x2="12" y2="15"/> |
| 184 |
</svg> |
| 185 |
<?php esc_html_e('Injection', 'king-addons'); ?> |
| 186 |
</h3> |
| 187 |
<div class="kng-cc-sidebar-content"> |
| 188 |
<div class="kng-v3-field"> |
| 189 |
<label class="kng-v3-label"><?php esc_html_e('Location', 'king-addons'); ?></label> |
| 190 |
<select name="location" id="kng-cc-location" class="kng-v3-select"> |
| 191 |
<option value="head" <?php selected($config['location'], 'head'); ?>><?php esc_html_e('Head (wp_head)', 'king-addons'); ?></option> |
| 192 |
<option value="footer" <?php selected($config['location'], 'footer'); ?>><?php esc_html_e('Footer (wp_footer)', 'king-addons'); ?></option> |
| 193 |
<?php if ($has_pro): ?> |
| 194 |
<option value="body_open" <?php selected($config['location'], 'body_open'); ?>><?php esc_html_e('Body Open (wp_body_open)', 'king-addons'); ?></option> |
| 195 |
<option value="custom_hook" <?php selected($config['location'], 'custom_hook'); ?>><?php esc_html_e('Custom Hook', 'king-addons'); ?></option> |
| 196 |
<?php else: ?> |
| 197 |
<option value="body_open" disabled><?php esc_html_e('Body Open', 'king-addons'); ?> (PRO)</option> |
| 198 |
<option value="custom_hook" disabled><?php esc_html_e('Custom Hook', 'king-addons'); ?> (PRO)</option> |
| 199 |
<?php endif; ?> |
| 200 |
</select> |
| 201 |
</div> |
| 202 |
|
| 203 |
<div class="kng-v3-field kng-cc-custom-hook-field" id="kng-cc-custom-hook-wrap" style="<?php echo $config['location'] !== 'custom_hook' ? 'display: none;' : ''; ?>"> |
| 204 |
<label class="kng-v3-label"><?php esc_html_e('Hook Name', 'king-addons'); ?></label> |
| 205 |
<input type="text" name="custom_hook" id="kng-cc-custom-hook" class="kng-v3-input" placeholder="my_custom_hook" value="<?php echo esc_attr($config['custom_hook']); ?>" /> |
| 206 |
</div> |
| 207 |
|
| 208 |
<div class="kng-v3-field"> |
| 209 |
<label class="kng-v3-label"><?php esc_html_e('Priority', 'king-addons'); ?></label> |
| 210 |
<input type="number" name="priority" id="kng-cc-priority" class="kng-v3-input" min="1" max="9999" value="<?php echo esc_attr($config['priority']); ?>" /> |
| 211 |
<p class="kng-v3-field-help"><?php esc_html_e('Lower numbers run first (default: 10)', 'king-addons'); ?></p> |
| 212 |
</div> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
|
| 216 |
<!-- JS Options (only for JS type) --> |
| 217 |
<div class="kng-cc-sidebar-section kng-cc-js-options" id="kng-cc-js-options" style="<?php echo $config['type'] !== 'js' ? 'display: none;' : ''; ?>"> |
| 218 |
<h3 class="kng-cc-sidebar-title"> |
| 219 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18"> |
| 220 |
<circle cx="12" cy="12" r="3"/> |
| 221 |
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/> |
| 222 |
</svg> |
| 223 |
<?php esc_html_e('JavaScript Options', 'king-addons'); ?> |
| 224 |
</h3> |
| 225 |
<div class="kng-cc-sidebar-content"> |
| 226 |
<div class="kng-v3-field"> |
| 227 |
<label class="kng-v3-toggle-wrap kng-v3-toggle-row"> |
| 228 |
<input type="checkbox" name="js_dom_ready" id="kng-cc-js-dom-ready" <?php checked($config['js_dom_ready']); ?> /> |
| 229 |
<span class="kng-v3-toggle-slider"></span> |
| 230 |
<span class="kng-v3-toggle-text"><?php esc_html_e('Wrap in DOMContentLoaded', 'king-addons'); ?></span> |
| 231 |
</label> |
| 232 |
</div> |
| 233 |
|
| 234 |
<div class="kng-v3-field <?php echo !$has_pro ? 'is-pro-field' : ''; ?>"> |
| 235 |
<label class="kng-v3-toggle-wrap kng-v3-toggle-row"> |
| 236 |
<input type="checkbox" name="js_defer" id="kng-cc-js-defer" <?php checked($config['js_defer']); ?> <?php echo !$has_pro ? 'disabled' : ''; ?> /> |
| 237 |
<span class="kng-v3-toggle-slider"></span> |
| 238 |
<span class="kng-v3-toggle-text"> |
| 239 |
<?php esc_html_e('Defer', 'king-addons'); ?> |
| 240 |
<?php if (!$has_pro): ?><span class="kng-cc-pro-badge-sm">PRO</span><?php endif; ?> |
| 241 |
</span> |
| 242 |
</label> |
| 243 |
</div> |
| 244 |
|
| 245 |
<div class="kng-v3-field <?php echo !$has_pro ? 'is-pro-field' : ''; ?>"> |
| 246 |
<label class="kng-v3-toggle-wrap kng-v3-toggle-row"> |
| 247 |
<input type="checkbox" name="js_async" id="kng-cc-js-async" <?php checked($config['js_async']); ?> <?php echo !$has_pro ? 'disabled' : ''; ?> /> |
| 248 |
<span class="kng-v3-toggle-slider"></span> |
| 249 |
<span class="kng-v3-toggle-text"> |
| 250 |
<?php esc_html_e('Async', 'king-addons'); ?> |
| 251 |
<?php if (!$has_pro): ?><span class="kng-cc-pro-badge-sm">PRO</span><?php endif; ?> |
| 252 |
</span> |
| 253 |
</label> |
| 254 |
</div> |
| 255 |
|
| 256 |
<div class="kng-v3-field <?php echo !$has_pro ? 'is-pro-field' : ''; ?>"> |
| 257 |
<label class="kng-v3-toggle-wrap kng-v3-toggle-row"> |
| 258 |
<input type="checkbox" name="js_module" id="kng-cc-js-module" <?php checked($config['js_module']); ?> <?php echo !$has_pro ? 'disabled' : ''; ?> /> |
| 259 |
<span class="kng-v3-toggle-slider"></span> |
| 260 |
<span class="kng-v3-toggle-text"> |
| 261 |
<?php esc_html_e('ES Module', 'king-addons'); ?> |
| 262 |
<?php if (!$has_pro): ?><span class="kng-cc-pro-badge-sm">PRO</span><?php endif; ?> |
| 263 |
</span> |
| 264 |
</label> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
</div> |
| 268 |
|
| 269 |
<!-- Targeting Rules --> |
| 270 |
<div class="kng-cc-sidebar-section kng-cc-rules-section"> |
| 271 |
<h3 class="kng-cc-sidebar-title"> |
| 272 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18"> |
| 273 |
<circle cx="12" cy="12" r="10"/> |
| 274 |
<circle cx="12" cy="12" r="6"/> |
| 275 |
<circle cx="12" cy="12" r="2"/> |
| 276 |
</svg> |
| 277 |
<?php esc_html_e('Targeting Rules', 'king-addons'); ?> |
| 278 |
</h3> |
| 279 |
<div class="kng-cc-sidebar-content"> |
| 280 |
<div class="kng-v3-field"> |
| 281 |
<label class="kng-v3-label"><?php esc_html_e('Scope', 'king-addons'); ?></label> |
| 282 |
<div class="kng-cc-scope-options"> |
| 283 |
<label class="kng-cc-radio-card <?php echo $config['scope_mode'] === 'global' ? 'is-selected' : ''; ?>"> |
| 284 |
<input type="radio" name="scope_mode" value="global" <?php checked($config['scope_mode'], 'global'); ?> /> |
| 285 |
<span class="kng-cc-radio-card-content"> |
| 286 |
<span class="kng-cc-radio-icon"> |
| 287 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"> |
| 288 |
<circle cx="12" cy="12" r="10"/> |
| 289 |
</svg> |
| 290 |
</span> |
| 291 |
<span class="kng-cc-radio-text"><?php esc_html_e('Global', 'king-addons'); ?></span> |
| 292 |
</span> |
| 293 |
</label> |
| 294 |
<label class="kng-cc-radio-card <?php echo $config['scope_mode'] === 'include' ? 'is-selected' : ''; ?> <?php echo !$has_pro ? 'is-pro-field' : ''; ?>"> |
| 295 |
<input type="radio" name="scope_mode" value="include" <?php checked($config['scope_mode'], 'include'); ?> <?php echo !$has_pro ? 'disabled' : ''; ?> /> |
| 296 |
<span class="kng-cc-radio-card-content"> |
| 297 |
<span class="kng-cc-radio-icon"> |
| 298 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"> |
| 299 |
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/> |
| 300 |
<polyline points="22 4 12 14.01 9 11.01"/> |
| 301 |
</svg> |
| 302 |
</span> |
| 303 |
<span class="kng-cc-radio-text"><?php esc_html_e('Include', 'king-addons'); ?><?php if (!$has_pro): ?> <span class="kng-cc-pro-badge-sm">PRO</span><?php endif; ?></span> |
| 304 |
</span> |
| 305 |
</label> |
| 306 |
<label class="kng-cc-radio-card <?php echo $config['scope_mode'] === 'exclude' ? 'is-selected' : ''; ?> <?php echo !$has_pro ? 'is-pro-field' : ''; ?>"> |
| 307 |
<input type="radio" name="scope_mode" value="exclude" <?php checked($config['scope_mode'], 'exclude'); ?> <?php echo !$has_pro ? 'disabled' : ''; ?> /> |
| 308 |
<span class="kng-cc-radio-card-content"> |
| 309 |
<span class="kng-cc-radio-icon"> |
| 310 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20"> |
| 311 |
<circle cx="12" cy="12" r="10"/> |
| 312 |
<line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/> |
| 313 |
</svg> |
| 314 |
</span> |
| 315 |
<span class="kng-cc-radio-text"><?php esc_html_e('Exclude', 'king-addons'); ?><?php if (!$has_pro): ?> <span class="kng-cc-pro-badge-sm">PRO</span><?php endif; ?></span> |
| 316 |
</span> |
| 317 |
</label> |
| 318 |
</div> |
| 319 |
</div> |
| 320 |
|
| 321 |
<!-- Rules Builder --> |
| 322 |
<div class="kng-cc-rules-builder" id="kng-cc-rules-builder" style="<?php echo $config['scope_mode'] === 'global' ? 'display: none;' : ''; ?>"> |
| 323 |
<?php if ($has_pro): ?> |
| 324 |
<div class="kng-v3-field"> |
| 325 |
<label class="kng-v3-label"><?php esc_html_e('Match Mode', 'king-addons'); ?></label> |
| 326 |
<select name="match_mode" id="kng-cc-match-mode" class="kng-v3-select"> |
| 327 |
<option value="any" <?php selected($config['match_mode'], 'any'); ?>><?php esc_html_e('Match ANY rule', 'king-addons'); ?></option> |
| 328 |
<option value="all" <?php selected($config['match_mode'], 'all'); ?>><?php esc_html_e('Match ALL rules', 'king-addons'); ?></option> |
| 329 |
</select> |
| 330 |
</div> |
| 331 |
<?php endif; ?> |
| 332 |
|
| 333 |
<div class="kng-cc-rules-list" id="kng-cc-rules-list"> |
| 334 |
<!-- Rules will be rendered by JS --> |
| 335 |
</div> |
| 336 |
|
| 337 |
<button type="button" class="kng-v3-btn kng-v3-btn--ghost kng-v3-btn--sm kng-cc-add-rule-btn" id="kng-cc-add-rule"> |
| 338 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"> |
| 339 |
<line x1="12" y1="5" x2="12" y2="19"/> |
| 340 |
<line x1="5" y1="12" x2="19" y2="12"/> |
| 341 |
</svg> |
| 342 |
<?php esc_html_e('Add Rule', 'king-addons'); ?> |
| 343 |
</button> |
| 344 |
</div> |
| 345 |
</div> |
| 346 |
</div> |
| 347 |
|
| 348 |
<?php if (!$has_pro): ?> |
| 349 |
<!-- Pro Features Upsell --> |
| 350 |
<div class="kng-cc-sidebar-section kng-cc-pro-section"> |
| 351 |
<div class="kng-cc-pro-box"> |
| 352 |
<div class="kng-cc-pro-box-icon"> |
| 353 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" width="22" height="22"> |
| 354 |
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/> |
| 355 |
</svg> |
| 356 |
</div> |
| 357 |
<h4><?php esc_html_e('Unlock All Features', 'king-addons'); ?></h4> |
| 358 |
<p class="kng-cc-pro-box-subtitle"><?php esc_html_e('Get the most out of Custom Code Manager', 'king-addons'); ?></p> |
| 359 |
<ul class="kng-cc-pro-features-list"> |
| 360 |
<li><?php esc_html_e('Unlimited snippets', 'king-addons'); ?></li> |
| 361 |
<li><?php esc_html_e('Include & Exclude targeting', 'king-addons'); ?></li> |
| 362 |
<li><?php esc_html_e('HTML snippet support', 'king-addons'); ?></li> |
| 363 |
<li><?php esc_html_e('Body Open & Custom Hooks', 'king-addons'); ?></li> |
| 364 |
<li><?php esc_html_e('Defer, Async & ES Module', 'king-addons'); ?></li> |
| 365 |
<li><?php esc_html_e('User role & device rules', 'king-addons'); ?></li> |
| 366 |
</ul> |
| 367 |
<a href="https://kingaddons.com/pricing/?utm_source=kng-custom-code&utm_medium=wp-admin&utm_campaign=kng" target="_blank" rel="noopener" class="kng-v3-btn kng-v3-btn--accent kng-v3-btn--sm" style="width:100%;justify-content:center;"> |
| 368 |
<?php esc_html_e('Upgrade to Pro', 'king-addons'); ?> |
| 369 |
</a> |
| 370 |
</div> |
| 371 |
</div> |
| 372 |
<?php endif; ?> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
</form> |
| 376 |
</div> |
| 377 |
|
| 378 |
<!-- Rule Template --> |
| 379 |
<script type="text/html" id="kng-cc-rule-template"> |
| 380 |
<div class="kng-cc-rule" data-index="{{index}}"> |
| 381 |
<div class="kng-cc-rule-header"> |
| 382 |
<select class="kng-v3-select kng-cc-rule-type" name="rules[{{index}}][type]"> |
| 383 |
<optgroup label="<?php esc_attr_e('Content', 'king-addons'); ?>"> |
| 384 |
<option value="page"><?php esc_html_e('Specific Page', 'king-addons'); ?></option> |
| 385 |
<option value="post"><?php esc_html_e('Specific Post', 'king-addons'); ?></option> |
| 386 |
<option value="post_type"><?php esc_html_e('Post Type', 'king-addons'); ?></option> |
| 387 |
<?php if ($has_pro): ?> |
| 388 |
<option value="taxonomy"><?php esc_html_e('Taxonomy', 'king-addons'); ?></option> |
| 389 |
<?php endif; ?> |
| 390 |
</optgroup> |
| 391 |
<optgroup label="<?php esc_attr_e('Special Pages', 'king-addons'); ?>"> |
| 392 |
<option value="front_page"><?php esc_html_e('Front Page', 'king-addons'); ?></option> |
| 393 |
<option value="blog_page"><?php esc_html_e('Blog Page', 'king-addons'); ?></option> |
| 394 |
<option value="archive"><?php esc_html_e('Archive Pages', 'king-addons'); ?></option> |
| 395 |
<option value="search"><?php esc_html_e('Search Results', 'king-addons'); ?></option> |
| 396 |
<option value="404"><?php esc_html_e('404 Page', 'king-addons'); ?></option> |
| 397 |
</optgroup> |
| 398 |
<optgroup label="<?php esc_attr_e('URL', 'king-addons'); ?>"> |
| 399 |
<option value="url_contains"><?php esc_html_e('URL Contains', 'king-addons'); ?></option> |
| 400 |
<?php if ($has_pro): ?> |
| 401 |
<option value="url_starts"><?php esc_html_e('URL Starts With', 'king-addons'); ?></option> |
| 402 |
<option value="url_ends"><?php esc_html_e('URL Ends With', 'king-addons'); ?></option> |
| 403 |
<option value="url_regex"><?php esc_html_e('URL Regex', 'king-addons'); ?></option> |
| 404 |
<?php endif; ?> |
| 405 |
</optgroup> |
| 406 |
<?php if ($has_pro): ?> |
| 407 |
<optgroup label="<?php esc_attr_e('User', 'king-addons'); ?>"> |
| 408 |
<option value="user_logged_in"><?php esc_html_e('User Logged In', 'king-addons'); ?></option> |
| 409 |
<option value="user_role"><?php esc_html_e('User Role', 'king-addons'); ?></option> |
| 410 |
</optgroup> |
| 411 |
<optgroup label="<?php esc_attr_e('Device', 'king-addons'); ?>"> |
| 412 |
<option value="device"><?php esc_html_e('Device Type', 'king-addons'); ?></option> |
| 413 |
</optgroup> |
| 414 |
<?php endif; ?> |
| 415 |
</select> |
| 416 |
<button type="button" class="kng-cc-rule-remove" title="<?php esc_attr_e('Remove', 'king-addons'); ?>"> |
| 417 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"> |
| 418 |
<line x1="18" y1="6" x2="6" y2="18"/> |
| 419 |
<line x1="6" y1="6" x2="18" y2="18"/> |
| 420 |
</svg> |
| 421 |
</button> |
| 422 |
</div> |
| 423 |
<div class="kng-cc-rule-value"> |
| 424 |
<!-- Value field rendered based on type --> |
| 425 |
</div> |
| 426 |
</div> |
| 427 |
</script> |
| 428 |
|