From e907a9621b9433462712db16f2de65672ef8433c Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 20:40:29 +0300 Subject: [PATCH 1/7] Refactor menu badge addition to prevent WP screen ID conflicts Move badge addition after add_menu_page to maintain stable WordPress screen IDs which use sanitize_title($menu_title). Extract badge logic into separate add_menu_badge() method that modifies global $menu array directly instead of concatenating to menu name before registration. --- classes/controllers/FrmAppController.php | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 71652478aa..64cb154de1 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -17,11 +17,34 @@ public static function menu() { $menu_name = FrmAppHelper::get_menu_name(); + add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() ); + + // Add the badge after `add_menu_page` to keep WP screen IDs stable they use `sanitize_title( $menu_title )`. if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) { - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() ); + self::add_menu_badge(); } + } - add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() ); + /** + * Add the inbox count badge to the Formidable menu. + * + * @since x.x + * + * @return void + */ + public static function add_menu_badge() { + global $menu; + + $badge = wp_kses_post( FrmInboxController::get_notice_count() ); + if ( ! $badge ) { + return; + } + + $menu_item = wp_list_filter( $menu, array( 2 => 'formidable' ) ); + if ( $menu_item ) { + // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Standard pattern for adding menu badges. + $menu[ key( $menu_item ) ][0] .= $badge; + } } /** From 2ffe720cab28f4a2042e8055360ec28148dffb8b Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 20:41:08 +0300 Subject: [PATCH 2/7] Remove unread count from dashboard filter hook to prevent WP screen ID conflicts Stop concatenating unread inbox count to filter hook name which was causing WordPress screen ID mismatches. Use base sanitized menu name only in manage_{screen}_columns filter to maintain stable screen identification. --- classes/controllers/FrmDashboardController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/controllers/FrmDashboardController.php b/classes/controllers/FrmDashboardController.php index 8ae2c713f2..5edc4c9189 100644 --- a/classes/controllers/FrmDashboardController.php +++ b/classes/controllers/FrmDashboardController.php @@ -44,9 +44,7 @@ public static function load_page() { self::remove_admin_notices_on_dashboard(); self::load_assets(); - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); - - add_filter( 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-dashboard_columns', 'FrmDashboardController::entries_columns' ); + add_filter( 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . '_page_formidable-dashboard_columns', 'FrmDashboardController::entries_columns' ); add_filter( 'frm_show_footer_links', '__return_false' ); add_filter( 'screen_options_show_screen', '__return_false' ); } From ae08f8da7923c5d37ec89d588f946675379b5dd3 Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 20:41:28 +0300 Subject: [PATCH 3/7] Remove unread count from entries screen ID to prevent WordPress screen ID conflicts Stop concatenating unread inbox count to screen ID which was causing WordPress screen ID mismatches. Use base sanitized menu name only in remove_screen_options() and get_screen_id() to maintain stable screen identification. --- classes/controllers/FrmEntriesController.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/classes/controllers/FrmEntriesController.php b/classes/controllers/FrmEntriesController.php index f96f41e35a..c4a4cd1c7b 100644 --- a/classes/controllers/FrmEntriesController.php +++ b/classes/controllers/FrmEntriesController.php @@ -150,10 +150,9 @@ public static function route() { * @return bool */ public static function remove_screen_options( $show_screen, $screen ) { - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) { + if ( $screen->id === $menu_name . '_page_formidable-entries' ) { $show_screen = false; } @@ -440,9 +439,7 @@ private static function base_column_key( $menu_name = '' ) { $menu_name = FrmAppHelper::get_menu_name(); } - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); - - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries'; + return sanitize_title( $menu_name ) . '_page_formidable-entries'; } /** From 2ec037bab8748f0beaef3e03bc1fc9ce5ccc2521 Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 20:41:48 +0300 Subject: [PATCH 4/7] Remove unread count from payments screen ID to prevent WordPress screen ID conflicts Stop concatenating unread inbox count to screen ID which was causing WordPress screen ID mismatches. Use base sanitized menu name only in add_list_hooks() and remove_screen_options() to maintain stable screen identification. --- stripe/controllers/FrmTransLiteListsController.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stripe/controllers/FrmTransLiteListsController.php b/stripe/controllers/FrmTransLiteListsController.php index f4022d8b0f..b71dcccd17 100755 --- a/stripe/controllers/FrmTransLiteListsController.php +++ b/stripe/controllers/FrmTransLiteListsController.php @@ -9,8 +9,7 @@ class FrmTransLiteListsController { * @return void */ public static function add_list_hooks() { - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); - $hook_name = 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-payments_columns'; + $hook_name = 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . '_page_formidable-payments_columns'; add_filter( $hook_name, self::class . '::payment_columns' ); add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 ); @@ -92,12 +91,7 @@ public static function remove_screen_options( $show_screen, $screen ) { return $show_screen; } - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); - - if ( $unread_count ) { - $menu_name .= '-' . $unread_count; - } + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); if ( $screen->id === $menu_name . '_page_formidable-payments' ) { $show_screen = false; From 8765c3784681ccd3ae3a28aaa34e80c283d6a4a7 Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 20:42:05 +0300 Subject: [PATCH 5/7] Deprecate get_visible_unread_inbox_count() helper method Mark FrmEntriesHelper::get_visible_unread_inbox_count() as deprecated and return 0. Remove inbox count calculation logic that was causing WordPress screen ID conflicts by modifying menu names after registration. --- classes/helpers/FrmEntriesHelper.php | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php index 3123be8cb9..19ca3aba55 100644 --- a/classes/helpers/FrmEntriesHelper.php +++ b/classes/helpers/FrmEntriesHelper.php @@ -947,31 +947,12 @@ public static function get_entry_statuses() { /** * @since 6.17 + * @deprecated x.x * * @return int */ public static function get_visible_unread_inbox_count() { - $menu_name = FrmAppHelper::get_menu_name(); - - if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) { - return 0; - } - - $inbox = new FrmInbox(); - $inbox_count = count( $inbox->unread() ); - - if ( ! $inbox_count ) { - return 0; - } - - if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) { - $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count ); - - if ( ! $inbox_count ) { - return 0; - } - } - - return $inbox_count; + _deprecated_function( __METHOD__, 'x.x' ); + return 0; } } From 9a5c2922e6872e141eab8e60c00005bcca6574d8 Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 21:40:32 +0300 Subject: [PATCH 6/7] Add blank line after wp_list_filter call for code readability --- classes/controllers/FrmAppController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 86ddc3d13d..e5551a5416 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -41,6 +41,7 @@ public static function add_menu_badge() { } $menu_item = wp_list_filter( $menu, array( 2 => 'formidable' ) ); + if ( $menu_item ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Standard pattern for adding menu badges. $menu[ key( $menu_item ) ][0] .= $badge; From 10d5caee45d92e35cffe5cf6e58446ddb9e03f00 Mon Sep 17 00:00:00 2001 From: Sherv Date: Mon, 12 Jan 2026 21:46:27 +0300 Subject: [PATCH 7/7] Add blank line after badge assignment for code readability --- classes/controllers/FrmAppController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index e5551a5416..598e61106c 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -36,6 +36,7 @@ public static function add_menu_badge() { global $menu; $badge = wp_kses_post( FrmInboxController::get_notice_count() ); + if ( ! $badge ) { return; }