From 3d810f2ef30a041acbbee990a801dcad68206915 Mon Sep 17 00:00:00 2001 From: Matt Gros <3311227+mpge@users.noreply.github.com> Date: Sun, 26 Apr 2026 23:36:18 -0400 Subject: [PATCH] fix(admin): stop ticket list rendering twice on the wp-admin page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `add_menu_page` auto-creates a submenu entry with the parent slug. Adding an explicit `add_submenu_page` with the same slug re-registers the `render_list` callback on the page-load hook, so the callback fires twice and the entire tickets table renders twice (visible in the bug-report screenshot at screenshots/results/ticket-list.png). Drop the redundant submenu registration and pass 'Tickets' as the menu_title — WordPress reuses that for the auto-created submenu so the sidebar still reads 'Tickets' under 'Escalated'. --- includes/Admin/class-admin-menu.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/Admin/class-admin-menu.php b/includes/Admin/class-admin-menu.php index 5b1701e..c3d4323 100644 --- a/includes/Admin/class-admin-menu.php +++ b/includes/Admin/class-admin-menu.php @@ -12,17 +12,25 @@ public function register(): void public function add_menus(): void { + // Top-level menu. WordPress auto-creates a submenu entry with + // the same slug pointing at the same callback. Adding an + // explicit add_submenu_page with that same slug ('escalated') + // re-registers the callback on the page-load hook, which makes + // render_list fire twice and the entire ticket list render + // twice on a single page view (see screenshots/results/ + // ticket-list.png in the bug-report screenshot pre-fix). + // Pass the desired submenu label as the menu_title argument + // and rely on the auto-created submenu — WordPress reuses the + // menu_title for that entry. add_menu_page( __('Escalated', 'escalated'), - __('Escalated', 'escalated'), + __('Tickets', 'escalated'), 'escalated_ticket_view', 'escalated', [new Admin_Tickets, 'render_list'], 'dashicons-tickets-alt', 30 ); - - add_submenu_page('escalated', __('Tickets', 'escalated'), __('Tickets', 'escalated'), 'escalated_ticket_view', 'escalated', [new Admin_Tickets, 'render_list']); add_submenu_page('escalated', __('Departments', 'escalated'), __('Departments', 'escalated'), 'escalated_department_view', 'escalated-departments', [new Admin_Departments, 'render']); add_submenu_page('escalated', __('SLA Policies', 'escalated'), __('SLA Policies', 'escalated'), 'escalated_sla_view', 'escalated-sla-policies', [new Admin_Sla_Policies, 'render']); add_submenu_page('escalated', __('Automations', 'escalated'), __('Automations', 'escalated'), 'escalated_automation_view', 'escalated-automations', [new Admin_Automations, 'render']);