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']; }); ?>

$label): ?>

PRO

$item_label): $row = $saved_endpoints[$slug] ?? [ 'label' => $item_label, 'enabled' => true, 'position' => 20, 'template_id' => 0, 'is_custom' => false, 'confirm' => false, 'roles' => [], ]; ?>
> > Yes' : 'No'; ?>
New