PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.44
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.44
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / admin / layouts / woo-builder-page.php

woo-builder-page.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.44, at includes/admin/layouts/woo-builder-page.php

629 lines 28.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WooCommerce Builder admin page - Modern Design.
4 *
5 * @package King_Addons
6 */
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 // Include shared dark theme support
13 include KING_ADDONS_PATH . 'includes/admin/shared/dark-theme.php';
14
15 wp_enqueue_style(KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-builder-style');
16
17 $can_use_pro = king_addons_can_use_pro();
18
19 $type_filter = isset($_GET['ka_woo_type']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_type'])) : '';
20 $status_filter = isset($_GET['ka_woo_status']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_status'])) : '';
21 $enabled_filter = isset($_GET['ka_woo_enabled']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_enabled'])) : '';
22
23 if (!empty($_GET['ka_woo_toggle']) && !empty($_GET['template_id'])) {
24 $template_id = (int) $_GET['template_id'];
25 if (current_user_can('manage_options') && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'] ?? '')), 'ka_woo_toggle_' . $template_id)) {
26 $conditions = get_post_meta($template_id, 'ka_woo_conditions', true);
27 if (!is_array($conditions)) {
28 $conditions = [];
29 }
30 $conditions['enabled'] = empty($conditions['enabled']);
31 update_post_meta($template_id, 'ka_woo_conditions', $conditions);
32 }
33 wp_safe_redirect(remove_query_arg(['ka_woo_toggle', 'template_id', '_wpnonce']));
34 exit;
35 }
36
37 $types = [
38 'single_product' => esc_html__('Single Product', 'king-addons'),
39 'product_archive' => esc_html__('Product Archive', 'king-addons'),
40 'cart' => esc_html__('Cart', 'king-addons'),
41 'checkout' => esc_html__('Checkout', 'king-addons'),
42 'my_account' => esc_html__('My Account', 'king-addons'),
43 ];
44
45 $endpoints_option_name = 'ka_woo_account_endpoints';
46 $saved_endpoints = get_option($endpoints_option_name, []);
47
48 if (
49 isset($_POST['ka_account_endpoints_save'])
50 && current_user_can('manage_options')
51 && check_admin_referer('ka_account_endpoints')
52 ) {
53 $endpoints_payload = $_POST['ka_endpoints'] ?? [];
54 $new_endpoints = [];
55
56 foreach ($endpoints_payload as $slug => $data) {
57 $slug = sanitize_title($slug);
58 if ('' === $slug) {
59 continue;
60 }
61 $new_endpoints[$slug] = [
62 'label' => sanitize_text_field($data['label'] ?? $slug),
63 'enabled' => !empty($data['enabled']),
64 'position' => isset($data['position']) ? (int) $data['position'] : 20,
65 'template_id' => isset($data['template_id']) ? (int) $data['template_id'] : 0,
66 'is_custom' => !empty($data['is_custom']),
67 'confirm' => !empty($data['confirm']),
68 'roles' => array_filter(array_map('sanitize_text_field', explode(',', $data['roles'] ?? ''))),
69 ];
70 }
71
72 if (!empty($_POST['ka_new_endpoint']['slug'])) {
73 $slug = sanitize_title($_POST['ka_new_endpoint']['slug']);
74 if ($slug) {
75 $new_endpoints[$slug] = [
76 'label' => sanitize_text_field($_POST['ka_new_endpoint']['label'] ?? $slug),
77 'enabled' => !empty($_POST['ka_new_endpoint']['enabled']),
78 'position' => (int) ($_POST['ka_new_endpoint']['position'] ?? 30),
79 'template_id' => (int) ($_POST['ka_new_endpoint']['template_id'] ?? 0),
80 'is_custom' => true,
81 'confirm' => !empty($_POST['ka_new_endpoint']['confirm']),
82 'roles' => array_filter(array_map('sanitize_text_field', explode(',', $_POST['ka_new_endpoint']['roles'] ?? ''))),
83 ];
84 }
85 }
86
87 update_option($endpoints_option_name, $new_endpoints);
88 flush_rewrite_rules(false);
89 $saved_endpoints = $new_endpoints;
90 add_settings_error('ka_account_endpoints', 'saved', esc_html__('My Account endpoints saved.', 'king-addons'), 'updated');
91 }
92
93 $default_account_items = function_exists('wc_get_account_menu_items') ? wc_get_account_menu_items() : [];
94
95 $rule_labels = [
96 'always' => esc_html__('Always', 'king-addons'),
97 'all_products' => esc_html__('All products', 'king-addons'),
98 'product_in' => esc_html__('Products', 'king-addons'),
99 'products' => esc_html__('Products', 'king-addons'),
100 'product_cat_in' => esc_html__('Product categories', 'king-addons'),
101 'product_categories' => esc_html__('Product categories', 'king-addons'),
102 'product_tag_in' => esc_html__('Product tags', 'king-addons'),
103 'product_tags' => esc_html__('Product tags', 'king-addons'),
104 'product_type_in' => esc_html__('Product types', 'king-addons'),
105 'product_types' => esc_html__('Product types', 'king-addons'),
106 'is_shop' => esc_html__('Shop page', 'king-addons'),
107 'shop' => esc_html__('Shop page', 'king-addons'),
108 'product_cat_archive_in' => esc_html__('Product category archives', 'king-addons'),
109 'product_cat_archives' => esc_html__('Product category archives', 'king-addons'),
110 'cart' => esc_html__('Cart page', 'king-addons'),
111 'checkout' => esc_html__('Checkout page', 'king-addons'),
112 'my_account' => esc_html__('My Account page', 'king-addons'),
113 ];
114
115 $create_links = [];
116 foreach ($types as $slug => $label) {
117 $create_links[$slug] = add_query_arg(
118 [
119 'post_type' => 'elementor_library',
120 'ka_woo_template_type' => $slug,
121 ],
122 admin_url('post-new.php')
123 );
124 }
125
126 $query = new WP_Query([
127 'post_type' => 'elementor_library',
128 'posts_per_page' => -1,
129 'post_status' => ['publish', 'draft', 'pending', 'future'],
130 'meta_query' => [
131 [
132 'key' => 'ka_woo_template_type',
133 'compare' => 'EXISTS',
134 ],
135 ],
136 ]);
137
138 $templates = [];
139
140 foreach ($query->posts as $post) {
141 $type = get_post_meta($post->ID, 'ka_woo_template_type', true);
142 if (empty($type)) {
143 continue;
144 }
145
146 $conditions = get_post_meta($post->ID, 'ka_woo_conditions', true);
147 $enabled = !empty($conditions['enabled']);
148 $priority = isset($conditions['priority']) ? (int) $conditions['priority'] : 10;
149 $rules = is_array($conditions['rules'] ?? null) ? $conditions['rules'] : [];
150
151 $rule_strings = [];
152 foreach ($rules as $rule) {
153 $rule_type = $rule['type'] ?? '';
154 $values = is_array($rule['values'] ?? null) ? $rule['values'] : [];
155 $label_text = $rule_labels[$rule_type] ?? $rule_type;
156 $values_display = '';
157 if (!empty($values)) {
158 $values_display = implode(', ', array_map('esc_html', array_map('strval', $values)));
159 }
160 $rule_strings[] = $values_display ? sprintf('%s: %s', $label_text, $values_display) : $label_text;
161 }
162
163 if (empty($rule_strings)) {
164 $rule_strings[] = $rule_labels['always'];
165 }
166
167 if ($type_filter && $type !== $type_filter) {
168 continue;
169 }
170
171 if ($status_filter && $post->post_status !== $status_filter) {
172 continue;
173 }
174
175 if ($enabled_filter === 'yes' && !$enabled) {
176 continue;
177 }
178
179 if ($enabled_filter === 'no' && $enabled) {
180 continue;
181 }
182
183 $pro_locked = (!$can_use_pro && in_array($type, ['cart', 'checkout', 'my_account'], true));
184
185 $templates[] = [
186 'id' => $post->ID,
187 'title' => get_the_title($post),
188 'type' => $type,
189 'enabled' => $enabled,
190 'priority' => $priority,
191 'rules_text' => implode('; ', $rule_strings),
192 'status' => $post->post_status,
193 'date' => get_the_modified_date('', $post),
194 'pro_locked' => $pro_locked,
195 ];
196 }
197
198 usort($templates, static function ($a, $b) {
199 return $a['priority'] <=> $b['priority'];
200 });
201 ?>
202 <style>
203 /* Modern WooCommerce Builder Styles */
204 .ka-woo-wrap {
205 max-width: 1400px;
206 margin: 20px 20px 20px 0;
207 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
208 }
209 .ka-woo-wrap * { box-sizing: border-box; }
210
211 /* Header */
212 .ka-woo-header {
213 background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
214 color: #fff;
215 padding: 25px 30px;
216 border-radius: 12px;
217 margin-bottom: 25px;
218 display: flex;
219 align-items: center;
220 justify-content: space-between;
221 }
222 .ka-woo-header h1 { margin: 0; font-size: 24px; font-weight: 600; color: #fff; }
223 .ka-woo-header-content { display: flex; align-items: center; gap: 16px; }
224 .ka-woo-header-icon {
225 width: 48px; height: 48px;
226 background: rgba(255,255,255,0.2);
227 border-radius: 12px;
228 display: flex; align-items: center; justify-content: center;
229 }
230 .ka-woo-header-icon .dashicons { font-size: 24px; width: 24px; height: 24px; color: #fff; }
231 .ka-woo-header p { margin: 4px 0 0; font-size: 14px; opacity: 0.9; }
232
233 /* Notices */
234 .ka-woo-wrap .notice { margin: 0 0 20px; border-radius: 8px; }
235
236 /* Cards */
237 .ka-card {
238 background: #fff; border-radius: 12px;
239 box-shadow: 0 1px 3px rgba(0,0,0,0.08);
240 margin-bottom: 20px; overflow: hidden;
241 }
242 .ka-card-header {
243 background: #f8fafc; padding: 16px 24px;
244 border-bottom: 1px solid #e2e8f0;
245 display: flex; align-items: center; gap: 10px;
246 }
247 .ka-card-header h2 { margin: 0; font-size: 15px; font-weight: 600; color: #1e293b; }
248 .ka-card-header .dashicons { color: #7c3aed; font-size: 18px; width: 18px; height: 18px; }
249 .ka-card-body { padding: 20px 24px; }
250
251 /* Template Type Buttons */
252 .ka-type-btns {
253 display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
254 }
255 .ka-type-btn {
256 display: inline-flex; align-items: center; gap: 8px;
257 background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
258 color: #fff; border: none; padding: 10px 18px;
259 border-radius: 8px; font-size: 13px; font-weight: 500;
260 text-decoration: none; cursor: pointer;
261 transition: transform 0.2s, box-shadow 0.2s;
262 }
263 .ka-type-btn:hover {
264 transform: translateY(-1px);
265 box-shadow: 0 4px 12px rgba(124,58,237,0.3);
266 color: #fff;
267 }
268 .ka-type-btn .dashicons { font-size: 16px; width: 16px; height: 16px; }
269
270 /* Filter Bar */
271 .ka-filter-bar {
272 background: #fff; border-radius: 12px;
273 box-shadow: 0 1px 3px rgba(0,0,0,0.08);
274 padding: 16px 24px; margin-bottom: 20px;
275 display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
276 }
277 .ka-filter-bar select {
278 padding: 8px 12px; border: 1px solid #e2e8f0;
279 border-radius: 6px; font-size: 14px; min-width: 140px;
280 }
281 .ka-filter-bar select:focus {
282 outline: none; border-color: #7c3aed;
283 box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
284 }
285 .ka-filter-bar .button { padding: 8px 16px; border-radius: 6px; }
286
287 /* Tables */
288 .ka-table {
289 width: 100%; border-collapse: collapse;
290 }
291 .ka-table th {
292 background: #f8fafc; padding: 12px 16px;
293 text-align: left; font-size: 12px; font-weight: 600;
294 color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;
295 border-bottom: 2px solid #e2e8f0;
296 }
297 .ka-table td {
298 padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
299 font-size: 14px; color: #334155;
300 }
301 .ka-table tbody tr:hover { background: #f8fafc; }
302 .ka-table a { color: #7c3aed; text-decoration: none; font-weight: 500; }
303 .ka-table a:hover { text-decoration: underline; }
304 .ka-table input[type="text"],
305 .ka-table input[type="number"],
306 .ka-table select {
307 padding: 6px 10px; border: 1px solid #e2e8f0;
308 border-radius: 6px; font-size: 13px;
309 }
310 .ka-table input[type="checkbox"] { width: 16px; height: 16px; }
311
312 /* Badge */
313 .ka-badge {
314 display: inline-block; padding: 4px 10px;
315 border-radius: 20px; font-size: 11px; font-weight: 500;
316 }
317 .ka-badge-success { background: #dcfce7; color: #166534; }
318 .ka-badge-warning { background: #fef3c7; color: #92400e; }
319 .ka-badge-neutral { background: #f3f4f6; color: #6b7280; }
320 .ka-badge-pro { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: #fff; }
321
322 /* Status */
323 .ka-status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
324 .ka-status-enabled { color: #059669; }
325 .ka-status-disabled { color: #dc2626; }
326
327 /* Actions */
328 .ka-actions { display: flex; gap: 8px; }
329 .ka-action-btn {
330 padding: 6px 12px; border-radius: 6px;
331 font-size: 12px; text-decoration: none;
332 border: 1px solid #e2e8f0; color: #475569;
333 background: #fff; cursor: pointer;
334 transition: all 0.2s;
335 }
336 .ka-action-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
337 .ka-action-btn-primary { background: #7c3aed; color: #fff; border-color: #7c3aed; }
338 .ka-action-btn-primary:hover { background: #6d28d9; color: #fff; }
339
340 /* Lock icon */
341 .ka-lock { color: #dc2626; margin-left: 6px; }
342
343 /* Submit section */
344 .ka-submit {
345 padding: 20px 24px;
346 background: #f8fafc; border-top: 1px solid #e2e8f0;
347 }
348 .ka-submit .button-primary {
349 background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
350 border: none; padding: 10px 24px;
351 font-size: 14px; font-weight: 500;
352 border-radius: 8px; cursor: pointer; color: #fff;
353 transition: transform 0.2s, box-shadow 0.2s;
354 }
355 .ka-submit .button-primary:hover {
356 transform: translateY(-1px);
357 box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
358 background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
359 }
360
361 /* Empty state */
362 .ka-empty {
363 text-align: center; padding: 40px 20px; color: #64748b;
364 }
365 .ka-empty .dashicons { font-size: 48px; width: 48px; height: 48px; opacity: 0.3; margin-bottom: 16px; }
366
367 /* Pro hint */
368 .ka-pro-hint { font-size: 12px; color: #64748b; font-style: italic; }
369
370 /* Responsive */
371 @media (max-width: 782px) {
372 .ka-woo-header { flex-direction: column; text-align: center; gap: 16px; }
373 .ka-filter-bar { flex-direction: column; align-items: stretch; }
374 .ka-table { display: block; overflow-x: auto; }
375 .ka-type-btns { flex-direction: column; }
376 }
377
378 /* Style Filter and Reset buttons */
379 .ka-filter-bar .button {
380 background: #334155;
381 border-color: #475569;
382 color: #f1f5f9;
383 padding: 8px 16px;
384 border-radius: 6px;
385 cursor: pointer;
386 transition: all 0.2s;
387 }
388 .ka-filter-bar .button:hover {
389 background: #475569;
390 border-color: #7c3aed;
391 color: #fff;
392 }
393 </style>
394
395 <?php
396 // Output dark theme styles
397 ka_render_dark_theme_styles();
398
399 // Apply dark theme immediately if enabled
400 ka_render_dark_theme_init();
401 ?>
402
403 <div class="ka-woo-wrap">
404 <!-- Header -->
405 <div class="ka-woo-header">
406 <div class="ka-woo-header-content">
407 <div class="ka-woo-header-icon">
408 <span class="dashicons dashicons-cart"></span>
409 </div>
410 <div>
411 <h1><?php esc_html_e('WooCommerce Builder', 'king-addons'); ?></h1>
412 <p><?php esc_html_e('Build custom WooCommerce pages with Elementor', 'king-addons'); ?></p>
413 </div>
414 </div>
415 <?php ka_render_dark_theme_toggle(); ?>
416 </div>
417
418 <?php settings_errors('ka_account_endpoints'); ?>
419
420 <?php if (!$can_use_pro): ?>
421 <div class="notice notice-warning" style="border-radius: 8px; border-left-color: #f59e0b;">
422 <p><strong><?php esc_html_e('Pro Feature:', 'king-addons'); ?></strong> <?php esc_html_e('Cart, Checkout, and My Account templates require Pro.', 'king-addons'); ?></p>
423 </div>
424 <?php endif; ?>
425
426 <!-- Create Template Buttons -->
427 <div class="ka-type-btns">
428 <?php foreach ($types as $slug => $label): ?>
429 <a class="ka-type-btn" href="<?php echo esc_url($create_links[$slug]); ?>">
430 <span class="dashicons dashicons-plus-alt2"></span>
431 <?php echo esc_html(sprintf(__('Add %s', 'king-addons'), $label)); ?>
432 </a>
433 <?php endforeach; ?>
434 </div>
435
436 <!-- Filter Bar -->
437 <form method="get" class="ka-filter-bar">
438 <input type="hidden" name="page" value="king-addons-woo-builder">
439 <select name="ka_woo_type">
440 <option value=""><?php esc_html_e('All Types', 'king-addons'); ?></option>
441 <?php foreach ($types as $slug => $label): ?>
442 <option value="<?php echo esc_attr($slug); ?>" <?php selected($type_filter, $slug); ?>>
443 <?php echo esc_html($label); ?>
444 </option>
445 <?php endforeach; ?>
446 </select>
447 <select name="ka_woo_status">
448 <option value=""><?php esc_html_e('All Statuses', 'king-addons'); ?></option>
449 <option value="publish" <?php selected($status_filter, 'publish'); ?>><?php esc_html_e('Published', 'king-addons'); ?></option>
450 <option value="draft" <?php selected($status_filter, 'draft'); ?>><?php esc_html_e('Draft', 'king-addons'); ?></option>
451 </select>
452 <select name="ka_woo_enabled">
453 <option value=""><?php esc_html_e('All', 'king-addons'); ?></option>
454 <option value="yes" <?php selected($enabled_filter, 'yes'); ?>><?php esc_html_e('Enabled', 'king-addons'); ?></option>
455 <option value="no" <?php selected($enabled_filter, 'no'); ?>><?php esc_html_e('Disabled', 'king-addons'); ?></option>
456 </select>
457 <button class="button"><?php esc_html_e('Filter', 'king-addons'); ?></button>
458 <a class="button" href="<?php echo esc_url(remove_query_arg(['ka_woo_type', 'ka_woo_status', 'ka_woo_enabled'])); ?>"><?php esc_html_e('Reset', 'king-addons'); ?></a>
459 </form>
460
461 <!-- Templates Table -->
462 <div class="ka-card">
463 <div class="ka-card-header">
464 <span class="dashicons dashicons-layout"></span>
465 <h2><?php esc_html_e('Templates', 'king-addons'); ?></h2>
466 </div>
467 <div class="ka-card-body" style="padding: 0;">
468 <?php if (empty($templates)): ?>
469 <div class="ka-empty">
470 <span class="dashicons dashicons-welcome-widgets-menus"></span>
471 <p><?php esc_html_e('No templates found. Create your first template above.', 'king-addons'); ?></p>
472 </div>
473 <?php else: ?>
474 <table class="ka-table">
475 <thead>
476 <tr>
477 <th><?php esc_html_e('Title', 'king-addons'); ?></th>
478 <th><?php esc_html_e('Type', 'king-addons'); ?></th>
479 <th><?php esc_html_e('Status', 'king-addons'); ?></th>
480 <th><?php esc_html_e('Priority', 'king-addons'); ?></th>
481 <th><?php esc_html_e('Enabled', 'king-addons'); ?></th>
482 <th><?php esc_html_e('Rules', 'king-addons'); ?></th>
483 <th><?php esc_html_e('Modified', 'king-addons'); ?></th>
484 <th><?php esc_html_e('Actions', 'king-addons'); ?></th>
485 </tr>
486 </thead>
487 <tbody>
488 <?php foreach ($templates as $template): ?>
489 <tr>
490 <td>
491 <a href="<?php echo esc_url(get_edit_post_link($template['id'])); ?>">
492 <?php echo esc_html($template['title']); ?>
493 </a>
494 </td>
495 <td>
496 <?php echo esc_html($types[$template['type']] ?? $template['type']); ?>
497 <?php if (!empty($template['pro_locked'])): ?>
498 <span class="ka-badge ka-badge-pro"><?php esc_html_e('PRO', 'king-addons'); ?></span>
499 <?php endif; ?>
500 </td>
501 <td>
502 <span class="ka-badge <?php echo $template['status'] === 'publish' ? 'ka-badge-success' : 'ka-badge-neutral'; ?>">
503 <?php echo esc_html(ucfirst($template['status'])); ?>
504 </span>
505 </td>
506 <td><?php echo esc_html($template['priority']); ?></td>
507 <td>
508 <span class="ka-status <?php echo $template['enabled'] ? 'ka-status-enabled' : 'ka-status-disabled'; ?>">
509 <span class="dashicons dashicons-<?php echo $template['enabled'] ? 'yes' : 'no'; ?>"></span>
510 <?php echo $template['enabled'] ? esc_html__('Yes', 'king-addons') : esc_html__('No', 'king-addons'); ?>
511 </span>
512 </td>
513 <td><small><?php echo esc_html($template['rules_text']); ?></small></td>
514 <td><?php echo esc_html($template['date']); ?></td>
515 <td>
516 <div class="ka-actions">
517 <a class="ka-action-btn" href="<?php echo esc_url(get_edit_post_link($template['id'])); ?>"><?php esc_html_e('Edit', 'king-addons'); ?></a>
518 <?php if (empty($template['pro_locked'])): ?>
519 <a class="ka-action-btn" href="<?php echo esc_url(wp_nonce_url(add_query_arg([
520 'page' => 'king-addons-woo-builder',
521 'template_id' => $template['id'],
522 'ka_woo_toggle' => 1,
523 ], admin_url('admin.php')), 'ka_woo_toggle_' . $template['id'])); ?>">
524 <?php echo $template['enabled'] ? esc_html__('Disable', 'king-addons') : esc_html__('Enable', 'king-addons'); ?>
525 </a>
526 <?php endif; ?>
527 </div>
528 </td>
529 </tr>
530 <?php endforeach; ?>
531 </tbody>
532 </table>
533 <?php endif; ?>
534 </div>
535 </div>
536
537 <!-- My Account Endpoints -->
538 <div class="ka-card">
539 <div class="ka-card-header">
540 <span class="dashicons dashicons-admin-users"></span>
541 <h2><?php esc_html_e('My Account Endpoints', 'king-addons'); ?><?php if (!$can_use_pro): ?><span class="ka-badge ka-badge-pro" style="margin-left: 10px;">PRO</span><?php endif; ?></h2>
542 </div>
543 <form method="post">
544 <?php wp_nonce_field('ka_account_endpoints'); ?>
545 <div class="ka-card-body" style="padding: 0;">
546 <table class="ka-table">
547 <thead>
548 <tr>
549 <th><?php esc_html_e('Slug', 'king-addons'); ?></th>
550 <th><?php esc_html_e('Label', 'king-addons'); ?></th>
551 <th><?php esc_html_e('Position', 'king-addons'); ?></th>
552 <th><?php esc_html_e('Enabled', 'king-addons'); ?></th>
553 <th><?php esc_html_e('Template', 'king-addons'); ?></th>
554 <th><?php esc_html_e('Roles', 'king-addons'); ?></th>
555 <th><?php esc_html_e('Logout Confirm', 'king-addons'); ?></th>
556 <th><?php esc_html_e('Custom', 'king-addons'); ?></th>
557 </tr>
558 </thead>
559 <tbody>
560 <?php foreach ($default_account_items as $slug => $item_label):
561 $row = $saved_endpoints[$slug] ?? [
562 'label' => $item_label,
563 'enabled' => true,
564 'position' => 20,
565 'template_id' => 0,
566 'is_custom' => false,
567 'confirm' => false,
568 'roles' => [],
569 ];
570 ?>
571 <tr>
572 <td><code style="background:#f1f5f9;padding:2px 6px;border-radius:4px;"><?php echo esc_html($slug); ?></code></td>
573 <td><input type="text" name="ka_endpoints[<?php echo esc_attr($slug); ?>][label]" value="<?php echo esc_attr($row['label']); ?>" style="width:120px"></td>
574 <td><input type="number" name="ka_endpoints[<?php echo esc_attr($slug); ?>][position]" value="<?php echo esc_attr((string) ($row['position'] ?? 20)); ?>" style="width:60px"></td>
575 <td><input type="checkbox" name="ka_endpoints[<?php echo esc_attr($slug); ?>][enabled]" <?php checked(!empty($row['enabled'])); ?>></td>
576 <td>
577 <?php if ($can_use_pro): ?>
578 <select name="ka_endpoints[<?php echo esc_attr($slug); ?>][template_id]" style="min-width:120px">
579 <option value="0"><?php esc_html_e('Default', 'king-addons'); ?></option>
580 <?php foreach ($templates as $template):
581 if ($template['type'] !== 'my_account') continue;
582 ?>
583 <option value="<?php echo esc_attr($template['id']); ?>" <?php selected((int) ($row['template_id'] ?? 0), (int) $template['id']); ?>>
584 <?php echo esc_html($template['title']); ?>
585 </option>
586 <?php endforeach; ?>
587 </select>
588 <?php else: ?>
589 <span class="ka-pro-hint"><?php esc_html_e('Pro only', 'king-addons'); ?></span>
590 <?php endif; ?>
591 </td>
592 <td><input type="text" name="ka_endpoints[<?php echo esc_attr($slug); ?>][roles]" value="<?php echo esc_attr(implode(',', $row['roles'] ?? [])); ?>" style="width:100px" placeholder="role1,role2"></td>
593 <td><input type="checkbox" name="ka_endpoints[<?php echo esc_attr($slug); ?>][confirm]" <?php checked(!empty($row['confirm'])); ?>></td>
594 <td><?php echo !empty($row['is_custom']) ? '<span class="ka-badge ka-badge-success">Yes</span>' : '<span class="ka-badge ka-badge-neutral">No</span>'; ?></td>
595 </tr>
596 <?php endforeach; ?>
597 <?php if ($can_use_pro): ?>
598 <tr style="background: #fefce8;">
599 <td><input type="text" name="ka_new_endpoint[slug]" placeholder="custom-endpoint" style="width:120px"></td>
600 <td><input type="text" name="ka_new_endpoint[label]" placeholder="Custom Label" style="width:120px"></td>
601 <td><input type="number" name="ka_new_endpoint[position]" value="30" style="width:60px"></td>
602 <td><input type="checkbox" name="ka_new_endpoint[enabled]"></td>
603 <td>
604 <select name="ka_new_endpoint[template_id]" style="min-width:120px">
605 <option value="0"><?php esc_html_e('Default', 'king-addons'); ?></option>
606 <?php foreach ($templates as $template):
607 if ($template['type'] !== 'my_account') continue;
608 ?>
609 <option value="<?php echo esc_attr($template['id']); ?>"><?php echo esc_html($template['title']); ?></option>
610 <?php endforeach; ?>
611 </select>
612 </td>
613 <td><input type="text" name="ka_new_endpoint[roles]" placeholder="role1,role2" style="width:100px"></td>
614 <td><input type="checkbox" name="ka_new_endpoint[confirm]"></td>
615 <td><span class="ka-badge ka-badge-warning">New</span></td>
616 </tr>
617 <?php endif; ?>
618 </tbody>
619 </table>
620 </div>
621 <div class="ka-submit">
622 <button type="submit" name="ka_account_endpoints_save" class="button button-primary"><?php esc_html_e('Save Endpoints', 'king-addons'); ?></button>
623 <span class="ka-pro-hint" style="margin-left: 12px;"><?php esc_html_e('Template overrides and custom endpoints require Pro.', 'king-addons'); ?></span>
624 </div>
625 </form>
626 </div>
627 </div>
628 <?php ka_render_dark_theme_script(); ?>
629