Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#57022 closed defect (bug) (duplicate)

Admin body class using translated menu title as CSS class for plugins.

Reported by: andrewza Owned by:
Priority: normal Milestone:
Component: Administration Version: 6.1
Severity: minor Keywords:
Cc: Focuses:

Description

Working through non-English sites, I've noticed that the admin_body_class that is generated for a plugin admin/setting page is using the translated menu_title which breaks JavaScript/CSS that relies on that particular CSS class.

For example, here is how we create a top level menu page with submenu pages within this page:

add_menu_page( __( 'Memberships', 'paid-memberships-pro' ), __( 'Memberships', 'paid-memberships-pro' ), 'pmpro_memberships_menu', 'pmpro-dashboard', 'manage_options, 'dashicons-groups', 30 );

When viewing this page in the WordPress dashboard, for locales that have translated the word "Memberships" is also filtering the CSS generated class, which interferes with JavaScript/CSS that we load solely for this page.

When setting the locale, to Portuguese for example changes the CSS class from memberships_page_pmpro-membershiplevels to assinaturas_page_pmpro-membershiplevels.

The admin_body_class filter only allows for adding more CSS classes to the admin area and not filtering the default generated CSS classes which I understand why this wouldn't be wanted/needed.

If I edit the $menu_title parameter to not be translatable from the add_menu_page it works as intended.

Change History (1)

#1 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #18857.

Note: See TracTickets for help on using tickets.