[wp-trac] [WordPress Trac] #57022: Admin body class using translated menu title as CSS class for plugins.

WordPress Trac noreply at wordpress.org
Mon Nov 7 16:06:52 UTC 2022


#57022: Admin body class using translated menu title as CSS class for plugins.
----------------------------+-----------------------------
 Reporter:  andrewza        |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  6.1
 Severity:  minor           |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57022>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list