Opened 11 years ago
Last modified 4 weeks ago
#32940 new enhancement
Add IDs to Admin Hyperlinks
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | 4.3 |
| Component: | Administration | Keywords: | has-patch dev-feedback 2nd-opinion needs-refresh |
| Focuses: | Cc: |
Description
Suggestion: add Ids to the primary admin interface hyperlinks.
Adding IDs to primary anchor tags in the admin UI makes it far easier to create and maintain UI test suites such as Selenium IDE. UI testing catches problems that phpUnit is not designed to address.
Example: Pages / Add New
xpath = /html/body/div/div[1]/div[2]/ul/li[5]/ul/li[3]/a
css = html.wp-toolbar body.wp-admin.wp-core-ui.js.edit-php.auto-fold.admin-bar.post-type-page.branch-4-3.version-4-3.admin-color-fresh.locale-en-us.customize-support.sticky-menu.svg div#wpwrap div#adminmenumain div#adminmenuwrap ul#adminmenu li#menu-pages.wp-has-submenu.wp-has-current-submenu.wp-menu-open.menu-top.menu-icon-page ul.wp-submenu.wp-submenu-wrap li a
Would be nice to reference key elements with things like a#menu-page-add-new instead. Especially when updates to WP Core change the higher level HTML DOM classesor structures.
Attachments (1)
Change History (6)
#3
@
6 years ago
- Keywords has-patch added; needs-patch removed
Thank you @charlestonsw for the report.
Likewise thank you @gaurang484 for the patch submission. I'll mark the ticket as has-patch so it can receive a review.
#4
@
6 years ago
- Keywords needs-testing dev-feedback 2nd-opinion added; good-first-bug removed
- Milestone set to Future Release
32940.diff applies cleanly and seems to do the job, however I am concerned that it uses the menu label as a source for generating the id attribute, which depends on the used locale.
I've switched WordPress to my native language (not English) and the menu ids also changed. For the purpose requested by the reporter (to be able to address specific menu items by CSS and/or JS), this is not stable enough in my opinion.
Core folks, please chime in with thoughts and suggestions on how to otherwise address this better.
Thanks.
#5
@
4 weeks ago
- Keywords needs-refresh added; needs-testing removed
Test Report
Patch tested: https://core.trac.wordpress.org/attachment/ticket/32940/32940.diff
Steps to Reproduce / Test
- Log in to the WordPress admin dashboard.
- Navigate to Pages → Add New.
- Open browser developer tools and inspect the admin menu markup.
- Locate the submenu
<a>element for Add New. - Check whether the link contains a stable
idattribute.
Expected Results
- Admin menu links should have stable, language-independent id attributes.
- IDs should be based on internal menu slugs, not translated labels.
Environment
- WordPress: 7.0-alpha-61215-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 143.0.0.0
- OS: macOS
- Theme: Twenty Twenty-One 2.7
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.1
Actual Results
❌ The patch does not work with the current WordPress version.
The patch is outdated and incompatible with current WordPress core. A refreshed patch is required using menu slugs to ensure stable selectors for UI testing.
Added code to display ID for sub menu items in admin dashboard