# king-addons/51.1.44/includes/admin/layouts/woo-builder-page.php

King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder, version 51.1.44. 629 lines.

- Page: https://pluginprobe.com/plugins/king-addons/51.1.44/code/includes/admin/layouts/woo-builder-page.php
- Raw: https://pluginprobe.com/plugins/king-addons/51.1.44/raw/includes/admin/layouts/woo-builder-page.php
- Modified: 2025-12-27T05:19:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/king-addons/51.1.44/code/includes/admin/layouts/woo-builder-page.php#L10-L20`.

```php
<?php
/**
 * WooCommerce Builder admin page - Modern Design.
 *
 * @package King_Addons
 */

if (!defined('ABSPATH')) {
    exit;
}

// Include shared dark theme support
include KING_ADDONS_PATH . 'includes/admin/shared/dark-theme.php';

wp_enqueue_style(KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-builder-style');

$can_use_pro = king_addons_can_use_pro();

$type_filter = isset($_GET['ka_woo_type']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_type'])) : '';
$status_filter = isset($_GET['ka_woo_status']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_status'])) : '';
$enabled_filter = isset($_GET['ka_woo_enabled']) ? sanitize_text_field(wp_unslash($_GET['ka_woo_enabled'])) : '';

if (!empty($_GET['ka_woo_toggle']) && !empty($_GET['template_id'])) {
    $template_id = (int) $_GET['template_id'];
    if (current_user_can('manage_options') && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'] ?? '')), 'ka_woo_toggle_' . $template_id)) {
        $conditions = get_post_meta($template_id, 'ka_woo_conditions', true);
        if (!is_array($conditions)) {
            $conditions = [];
        }
        $conditions['enabled'] = empty($conditions['enabled']);
        update_post_meta($template_id, 'ka_woo_conditions', $conditions);
    }
    wp_safe_redirect(remove_query_arg(['ka_woo_toggle', 'template_id', '_wpnonce']));
    exit;
}

$types = [
    'single_product' => esc_html__('Single Product', 'king-addons'),
    'product_archive' => esc_html__('Product Archive', 'king-addons'),
    'cart' => esc_html__('Cart', 'king-addons'),
    'checkout' => esc_html__('Checkout', 'king-addons'),
    'my_account' => esc_html__('My Account', 'king-addons'),
];

$endpoints_option_name = 'ka_woo_account_endpoints';
$saved_endpoints = get_option($endpoints_option_name, []);

if (
    isset($_POST['ka_account_endpoints_save'])
    && current_user_can('manage_options')
    && check_admin_referer('ka_account_endpoints')
) {
    $endpoints_payload = $_POST['ka_endpoints'] ?? [];
    $new_endpoints = [];

    foreach ($endpoints_payload as $slug => $data) {
        $slug = sanitize_title($slug);
        if ('' === $slug) {
            continue;
        }
        $new_endpoints[$slug] = [
            'label' => sanitize_text_field($data['label'] ?? $slug),
            'enabled' => !empty($data['enabled']),
            'position' => isset($data['position']) ? (int) $data['position'] : 20,
            'template_id' => isset($data['template_id']) ? (int) $data['template_id'] : 0,
            'is_custom' => !empty($data['is_custom']),
            'confirm' => !empty($data['confirm']),
            'roles' => array_filter(array_map('sanitize_text_field', explode(',', $data['roles'] ?? ''))),
        ];
    }

    if (!empty($_POST['ka_new_endpoint']['slug'])) {
        $slug = sanitize_title($_POST['ka_new_endpoint']['slug']);
        if ($slug) {
            $new_endpoints[$slug] = [
                'label' => sanitize_text_field($_POST['ka_new_endpoint']['label'] ?? $slug),
                'enabled' => !empty($_POST['ka_new_endpoint']['enabled']),
                'position' => (int) ($_POST['ka_new_endpoint']['position'] ?? 30),
                'template_id' => (int) ($_POST['ka_new_endpoint']['template_id'] ?? 0),
                'is_custom' => true,
                'confirm' => !empty($_POST['ka_new_endpoint']['confirm']),
                'roles' => array_filter(array_map('sanitize_text_field', explode(',', $_POST['ka_new_endpoint']['roles'] ?? ''))),
            ];
        }
    }

    update_option($endpoints_option_name, $new_endpoints);
    flush_rewrite_rules(false);
    $saved_endpoints = $new_endpoints;
    add_settings_error('ka_account_endpoints', 'saved', esc_html__('My Account endpoints saved.', 'king-addons'), 'updated');
}

$default_account_items = function_exists('wc_get_account_menu_items') ? wc_get_account_menu_items() : [];

$rule_labels = [
    'always' => esc_html__('Always', 'king-addons'),
    'all_products' => esc_html__('All products', 'king-addons'),
    'product_in' => esc_html__('Products', 'king-addons'),
    'products' => esc_html__('Products', 'king-addons'),
    'product_cat_in' => esc_html__('Product categories', 'king-addons'),
    'product_categories' => esc_html__('Product categories', 'king-addons'),
    'product_tag_in' => esc_html__('Product tags', 'king-addons'),
    'product_tags' => esc_html__('Product tags', 'king-addons'),
    'product_type_in' => esc_html__('Product types', 'king-addons'),
    'product_types' => esc_html__('Product types', 'king-addons'),
    'is_shop' => esc_html__('Shop page', 'king-addons'),
    'shop' => esc_html__('Shop page', 'king-addons'),
    'product_cat_archive_in' => esc_html__('Product category archives', 'king-addons'),
    'product_cat_archives' => esc_html__('Product category archives', 'king-addons'),
    'cart' => esc_html__('Cart page', 'king-addons'),
    'checkout' => esc_html__('Checkout page', 'king-addons'),
    'my_account' => esc_html__('My Account page', 'king-addons'),
];

$create_links = [];
foreach ($types as $slug => $label) {
    $create_links[$slug] = add_query_arg(
        [
            'post_type' => 'elementor_library',
            'ka_woo_template_type' => $slug,
        ],
        admin_url('post-new.php')
    );
}

$query = new WP_Query([
    'post_type' => 'elementor_library',
    'posts_per_page' => -1,
    'post_status' => ['publish', 'draft', 'pending', 'future'],
    'meta_query' => [
        [
            'key' => 'ka_woo_template_type',
            'compare' => 'EXISTS',
        ],
    ],
]);

$templates = [];

foreach ($query->posts as $post) {
    $type = get_post_meta($post->ID, 'ka_woo_template_type', true);
    if (empty($type)) {
        continue;
    }

    $conditions = get_post_meta($post->ID, 'ka_woo_conditions', true);
    $enabled = !empty($conditions['enabled']);
    $priority = isset($conditions['priority']) ? (int) $conditions['priority'] : 10;
    $rules = is_array($conditions['rules'] ?? null) ? $conditions['rules'] : [];

    $rule_strings = [];
    foreach ($rules as $rule) {
        $rule_type = $rule['type'] ?? '';
        $values = is_array($rule['values'] ?? null) ? $rule['values'] : [];
        $label_text = $rule_labels[$rule_type] ?? $rule_type;
        $values_display = '';
        if (!empty($values)) {
            $values_display = implode(', ', array_map('esc_html', array_map('strval', $values)));
        }
        $rule_strings[] = $values_display ? sprintf('%s: %s', $label_text, $values_display) : $label_text;
    }

    if (empty($rule_strings)) {
        $rule_strings[] = $rule_labels['always'];
    }

    if ($type_filter && $type !== $type_filter) {
        continue;
    }

    if ($status_filter && $post->post_status !== $status_filter) {
        continue;
    }

    if ($enabled_filter === 'yes' && !$enabled) {
        continue;
    }

    if ($enabled_filter === 'no' && $enabled) {
        continue;
    }

    $pro_locked = (!$can_use_pro && in_array($type, ['cart', 'checkout', 'my_account'], true));

    $templates[] = [
        'id' => $post->ID,
        'title' => get_the_title($post),
        'type' => $type,
        'enabled' => $enabled,
        'priority' => $priority,
        'rules_text' => implode('; ', $rule_strings),
        'status' => $post->post_status,
        'date' => get_the_modified_date('', $post),
        'pro_locked' => $pro_locked,
    ];
}

usort($templates, static function ($a, $b) {
    return $a['priority'] <=> $b['priority'];
});
?>
<style>
/* Modern WooCommerce Builder Styles */
.ka-woo-wrap {
    max-width: 1400px;
    margin: 20px 20px 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.ka-woo-wrap * { box-sizing: border-box; }

/* Header */
.ka-woo-header {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
    padding: 25px 30px;
    border-radius: 12px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ka-woo-header h1 { margin: 0; font-size: 24px; font-weight: 600; color: #fff; }
.ka-woo-header-content { display: flex; align-items: center; gap: 16px; }
.ka-woo-header-icon {
    width: 48px; height: 48px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.ka-woo-header-icon .dashicons { font-size: 24px; width: 24px; height: 24px; color: #fff; }
.ka-woo-header p { margin: 4px 0 0; font-size: 14px; opacity: 0.9; }

/* Notices */
.ka-woo-wrap .notice { margin: 0 0 20px; border-radius: 8px; }

/* Cards */
.ka-card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px; overflow: hidden;
}
.ka-card-header {
    background: #f8fafc; padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; gap: 10px;
}
.ka-card-header h2 { margin: 0; font-size: 15px; font-weight: 600; color: #1e293b; }
.ka-card-header .dashicons { color: #7c3aed; font-size: 18px; width: 18px; height: 18px; }
.ka-card-body { padding: 20px 24px; }

/* Template Type Buttons */
.ka-type-btns {
    display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
}
.ka-type-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff; border: none; padding: 10px 18px;
    border-radius: 8px; font-size: 13px; font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ka-type-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124,58,237,0.3);
    color: #fff;
}
.ka-type-btn .dashicons { font-size: 16px; width: 16px; height: 16px; }

/* Filter Bar */
.ka-filter-bar {
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 16px 24px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.ka-filter-bar select {
    padding: 8px 12px; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 14px; min-width: 140px;
}
.ka-filter-bar select:focus {
    outline: none; border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.ka-filter-bar .button { padding: 8px 16px; border-radius: 6px; }

/* Tables */
.ka-table {
    width: 100%; border-collapse: collapse;
}
.ka-table th {
    background: #f8fafc; padding: 12px 16px;
    text-align: left; font-size: 12px; font-weight: 600;
    color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}
.ka-table td {
    padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
    font-size: 14px; color: #334155;
}
.ka-table tbody tr:hover { background: #f8fafc; }
.ka-table a { color: #7c3aed; text-decoration: none; font-weight: 500; }
.ka-table a:hover { text-decoration: underline; }
.ka-table input[type="text"],
.ka-table input[type="number"],
.ka-table select {
    padding: 6px 10px; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 13px;
}
.ka-table input[type="checkbox"] { width: 16px; height: 16px; }

/* Badge */
.ka-badge {
    display: inline-block; padding: 4px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 500;
}
.ka-badge-success { background: #dcfce7; color: #166534; }
.ka-badge-warning { background: #fef3c7; color: #92400e; }
.ka-badge-neutral { background: #f3f4f6; color: #6b7280; }
.ka-badge-pro { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: #fff; }

/* Status */
.ka-status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.ka-status-enabled { color: #059669; }
.ka-status-disabled { color: #dc2626; }

/* Actions */
.ka-actions { display: flex; gap: 8px; }
.ka-action-btn {
    padding: 6px 12px; border-radius: 6px;
    font-size: 12px; text-decoration: none;
    border: 1px solid #e2e8f0; color: #475569;
    background: #fff; cursor: pointer;
    transition: all 0.2s;
}
.ka-action-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.ka-action-btn-primary { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.ka-action-btn-primary:hover { background: #6d28d9; color: #fff; }

/* Lock icon */
.ka-lock { color: #dc2626; margin-left: 6px; }

/* Submit section */
.ka-submit {
    padding: 20px 24px;
    background: #f8fafc; border-top: 1px solid #e2e8f0;
}
.ka-submit .button-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    border: none; padding: 10px 24px;
    font-size: 14px; font-weight: 500;
    border-radius: 8px; cursor: pointer; color: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ka-submit .button-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
}

/* Empty state */
.ka-empty {
    text-align: center; padding: 40px 20px; color: #64748b;
}
.ka-empty .dashicons { font-size: 48px; width: 48px; height: 48px; opacity: 0.3; margin-bottom: 16px; }

/* Pro hint */
.ka-pro-hint { font-size: 12px; color: #64748b; font-style: italic; }

/* Responsive */
@media (max-width: 782px) {
    .ka-woo-header { flex-direction: column; text-align: center; gap: 16px; }
    .ka-filter-bar { flex-direction: column; align-items: stretch; }
    .ka-table { display: block; overflow-x: auto; }
    .ka-type-btns { flex-direction: column; }
}

/* Style Filter and Reset buttons */
.ka-filter-bar .button {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.ka-filter-bar .button:hover {
    background: #475569;
    border-color: #7c3aed;
    color: #fff;
}
</style>

<?php 
// Output dark theme styles
ka_render_dark_theme_styles();

// Apply dark theme immediately if enabled
ka_render_dark_theme_init();
?>

<div class="ka-woo-wrap">
    <!-- Header -->
    <div class="ka-woo-header">
        <div class="ka-woo-header-content">
            <div class="ka-woo-header-icon">
                <span class="dashicons dashicons-cart"></span>
            </div>
            <div>
                <h1><?php esc_html_e('WooCommerce Builder', 'king-addons'); ?></h1>
                <p><?php esc_html_e('Build custom WooCommerce pages with Elementor', 'king-addons'); ?></p>
            </div>
        </div>
        <?php ka_render_dark_theme_toggle(); ?>
    </div>

    <?php settings_errors('ka_account_endpoints'); ?>

    <?php if (!$can_use_pro): ?>
        <div class="notice notice-warning" style="border-radius: 8px; border-left-color: #f59e0b;">
            <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>
        </div>
    <?php endif; ?>

    <!-- Create Template Buttons -->
    <div class="ka-type-btns">
        <?php foreach ($types as $slug => $label): ?>
            <a class="ka-type-btn" href="<?php echo esc_url($create_links[$slug]); ?>">
                <span class="dashicons dashicons-plus-alt2"></span>
                <?php echo esc_html(sprintf(__('Add %s', 'king-addons'), $label)); ?>
            </a>
        <?php endforeach; ?>
    </div>

    <!-- Filter Bar -->
    <form method="get" class="ka-filter-bar">
        <input type="hidden" name="page" value="king-addons-woo-builder">
        <select name="ka_woo_type">
            <option value=""><?php esc_html_e('All Types', 'king-addons'); ?></option>
            <?php foreach ($types as $slug => $label): ?>
                <option value="<?php echo esc_attr($slug); ?>" <?php selected($type_filter, $slug); ?>>
                    <?php echo esc_html($label); ?>
                </option>
            <?php endforeach; ?>
        </select>
        <select name="ka_woo_status">
            <option value=""><?php esc_html_e('All Statuses', 'king-addons'); ?></option>
            <option value="publish" <?php selected($status_filter, 'publish'); ?>><?php esc_html_e('Published', 'king-addons'); ?></option>
            <option value="draft" <?php selected($status_filter, 'draft'); ?>><?php esc_html_e('Draft', 'king-addons'); ?></option>
        </select>
        <select name="ka_woo_enabled">
            <option value=""><?php esc_html_e('All', 'king-addons'); ?></option>
            <option value="yes" <?php selected($enabled_filter, 'yes'); ?>><?php esc_html_e('Enabled', 'king-addons'); ?></option>
            <option value="no" <?php selected($enabled_filter, 'no'); ?>><?php esc_html_e('Disabled', 'king-addons'); ?></option>
        </select>
        <button class="button"><?php esc_html_e('Filter', 'king-addons'); ?></button>
        <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>
    </form>

    <!-- Templates Table -->
    <div class="ka-card">
        <div class="ka-card-header">
            <span class="dashicons dashicons-layout"></span>
            <h2><?php esc_html_e('Templates', 'king-addons'); ?></h2>
        </div>
        <div class="ka-card-body" style="padding: 0;">
            <?php if (empty($templates)): ?>
                <div class="ka-empty">
                    <span class="dashicons dashicons-welcome-widgets-menus"></span>
                    <p><?php esc_html_e('No templates found. Create your first template above.', 'king-addons'); ?></p>
                </div>
            <?php else: ?>
                <table class="ka-table">
                    <thead>
                        <tr>
                            <th><?php esc_html_e('Title', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Type', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Status', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Priority', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Enabled', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Rules', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Modified', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Actions', 'king-addons'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($templates as $template): ?>
                            <tr>
                                <td>
                                    <a href="<?php echo esc_url(get_edit_post_link($template['id'])); ?>">
                                        <?php echo esc_html($template['title']); ?>
                                    </a>
                                </td>
                                <td>
                                    <?php echo esc_html($types[$template['type']] ?? $template['type']); ?>
                                    <?php if (!empty($template['pro_locked'])): ?>
                                        <span class="ka-badge ka-badge-pro"><?php esc_html_e('PRO', 'king-addons'); ?></span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <span class="ka-badge <?php echo $template['status'] === 'publish' ? 'ka-badge-success' : 'ka-badge-neutral'; ?>">
                                        <?php echo esc_html(ucfirst($template['status'])); ?>
                                    </span>
                                </td>
                                <td><?php echo esc_html($template['priority']); ?></td>
                                <td>
                                    <span class="ka-status <?php echo $template['enabled'] ? 'ka-status-enabled' : 'ka-status-disabled'; ?>">
                                        <span class="dashicons dashicons-<?php echo $template['enabled'] ? 'yes' : 'no'; ?>"></span>
                                        <?php echo $template['enabled'] ? esc_html__('Yes', 'king-addons') : esc_html__('No', 'king-addons'); ?>
                                    </span>
                                </td>
                                <td><small><?php echo esc_html($template['rules_text']); ?></small></td>
                                <td><?php echo esc_html($template['date']); ?></td>
                                <td>
                                    <div class="ka-actions">
                                        <a class="ka-action-btn" href="<?php echo esc_url(get_edit_post_link($template['id'])); ?>"><?php esc_html_e('Edit', 'king-addons'); ?></a>
                                        <?php if (empty($template['pro_locked'])): ?>
                                            <a class="ka-action-btn" href="<?php echo esc_url(wp_nonce_url(add_query_arg([
                                                'page' => 'king-addons-woo-builder',
                                                'template_id' => $template['id'],
                                                'ka_woo_toggle' => 1,
                                            ], admin_url('admin.php')), 'ka_woo_toggle_' . $template['id'])); ?>">
                                                <?php echo $template['enabled'] ? esc_html__('Disable', 'king-addons') : esc_html__('Enable', 'king-addons'); ?>
                                            </a>
                                        <?php endif; ?>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            <?php endif; ?>
        </div>
    </div>

    <!-- My Account Endpoints -->
    <div class="ka-card">
        <div class="ka-card-header">
            <span class="dashicons dashicons-admin-users"></span>
            <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>
        </div>
        <form method="post">
            <?php wp_nonce_field('ka_account_endpoints'); ?>
            <div class="ka-card-body" style="padding: 0;">
                <table class="ka-table">
                    <thead>
                        <tr>
                            <th><?php esc_html_e('Slug', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Label', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Position', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Enabled', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Template', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Roles', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Logout Confirm', 'king-addons'); ?></th>
                            <th><?php esc_html_e('Custom', 'king-addons'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($default_account_items as $slug => $item_label):
                            $row = $saved_endpoints[$slug] ?? [
                                'label' => $item_label,
                                'enabled' => true,
                                'position' => 20,
                                'template_id' => 0,
                                'is_custom' => false,
                                'confirm' => false,
                                'roles' => [],
                            ];
                        ?>
                            <tr>
                                <td><code style="background:#f1f5f9;padding:2px 6px;border-radius:4px;"><?php echo esc_html($slug); ?></code></td>
                                <td><input type="text" name="ka_endpoints[<?php echo esc_attr($slug); ?>][label]" value="<?php echo esc_attr($row['label']); ?>" style="width:120px"></td>
                                <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>
                                <td><input type="checkbox" name="ka_endpoints[<?php echo esc_attr($slug); ?>][enabled]" <?php checked(!empty($row['enabled'])); ?>></td>
                                <td>
                                    <?php if ($can_use_pro): ?>
                                        <select name="ka_endpoints[<?php echo esc_attr($slug); ?>][template_id]" style="min-width:120px">
                                            <option value="0"><?php esc_html_e('Default', 'king-addons'); ?></option>
                                            <?php foreach ($templates as $template):
                                                if ($template['type'] !== 'my_account') continue;
                                            ?>
                                                <option value="<?php echo esc_attr($template['id']); ?>" <?php selected((int) ($row['template_id'] ?? 0), (int) $template['id']); ?>>
                                                    <?php echo esc_html($template['title']); ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                    <?php else: ?>
                                        <span class="ka-pro-hint"><?php esc_html_e('Pro only', 'king-addons'); ?></span>
                                    <?php endif; ?>
                                </td>
                                <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>
                                <td><input type="checkbox" name="ka_endpoints[<?php echo esc_attr($slug); ?>][confirm]" <?php checked(!empty($row['confirm'])); ?>></td>
                                <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>
                            </tr>
                        <?php endforeach; ?>
                        <?php if ($can_use_pro): ?>
                            <tr style="background: #fefce8;">
                                <td><input type="text" name="ka_new_endpoint[slug]" placeholder="custom-endpoint" style="width:120px"></td>
                                <td><input type="text" name="ka_new_endpoint[label]" placeholder="Custom Label" style="width:120px"></td>
                                <td><input type="number" name="ka_new_endpoint[position]" value="30" style="width:60px"></td>
                                <td><input type="checkbox" name="ka_new_endpoint[enabled]"></td>
                                <td>
                                    <select name="ka_new_endpoint[template_id]" style="min-width:120px">
                                        <option value="0"><?php esc_html_e('Default', 'king-addons'); ?></option>
                                        <?php foreach ($templates as $template):
                                            if ($template['type'] !== 'my_account') continue;
                                        ?>
                                            <option value="<?php echo esc_attr($template['id']); ?>"><?php echo esc_html($template['title']); ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </td>
                                <td><input type="text" name="ka_new_endpoint[roles]" placeholder="role1,role2" style="width:100px"></td>
                                <td><input type="checkbox" name="ka_new_endpoint[confirm]"></td>
                                <td><span class="ka-badge ka-badge-warning">New</span></td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <div class="ka-submit">
                <button type="submit" name="ka_account_endpoints_save" class="button button-primary"><?php esc_html_e('Save Endpoints', 'king-addons'); ?></button>
                <span class="ka-pro-hint" style="margin-left: 12px;"><?php esc_html_e('Template overrides and custom endpoints require Pro.', 'king-addons'); ?></span>
            </div>
        </form>
    </div>
</div>
<?php ka_render_dark_theme_script(); ?>

```
