Opened 2 years ago
Closed 2 years ago
#57022 closed defect (bug) (duplicate)
Admin body class using translated menu title as CSS class for plugins.
Reported by: | andrewza | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 6.1 |
Component: | Administration | Keywords: | |
Focuses: | Cc: |
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.
Hi there, welcome to WordPress Trac!
Thanks for the report, we're already tracking this issue in #18857.