Opened 4 years ago
Last modified 3 months ago
#56302 new defect (bug)
Admin menu links have relative URLs
| Reported by: | iihglobal | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-screenshots dev-feedback has-patch has-test-info has-unit-tests |
| Cc: | Focuses: | administration |
Description (last modified by )
Hey,
When i opened abc.com/wp-admin/options.php/ and then try to go on submenu under settings then menu link is wrong and not opening page. more information you can see quick recording.
https://www.loom.com/share/e64670a986df4c5da8e81838799a7ea1
Thank you
Attachments (2)
Change History (8)
#2
@
4 years ago
- Component Menus → Administration
- Description modified (diff)
- Summary Menu link on admin side → Admin menu links have relative URLs
- Version 6.0
The trailing slash at the end of the options.php/ address is important to reproduce the error (@audrasjb tried on #56303). With relative links, the resulting URLs like abc.com/wp-admin/options.php/options-general.php keep opening the options.php page.
A plugin might have added the slash character, but maybe this situation is avoidable.
@
4 years ago
Use WP_Http::make_absolute_url() with admin_url() to make admin menu links relative to admin_url(). WP_Http::make_absolute_url() documentation states: "If an Absolute URL is provided, no processing of that URL is done."
#3
@
4 years ago
- Keywords dev-feedback has-patch has-testing-info needs-testing added
56302.diff is one way to resolve this issue by converting relative URLs to absolute URLs, relative to admin_url().
Testing Instructions
Steps to Reproduce
- Navigate to
/wp-admin/options.php/- Note the trailing slash. - Click
General. - 🐞 The contents do not change, but the URL changes to
/wp-admin/options.php/options-general.php. - Apply 56302.diff.
- Navigate to
/wp-admin/options.php/- Note the trailing slash. - Click
General.
Expected Results
- 🐞 Before the patch: The
options.phppage's contents remain, but the URL changes to/wp-admin/options.php/options-general.php. - ✅ After the patch: The contents change to the
Generalpage's contents, and the URL is/wp-admin/options-general.php.
Notes
- This patch is an example of one approach. Be aware that there are further changes required to the
WP_List_Tablesviews links, as well as all other relative links throughout the Dashboard. Not all would needWP_Http::make_absolute_url(), some just need to be wrapped inadmin_url(). I'm happy to continue this work to address the other areas, if this approach is desired. - Adding
dev-feedbackto see if this approach is desired or if there are other ideas of how to manage this throughout the Dashboard.
#4
@
4 years ago
- Keywords has-unit-tests added; needs-testing removed
I have tested as per solution shared by @costdev in 56302.diff and working fine.
Below you can watch the quick recording.
https://www.awesomescreenshot.com/video/12221736?key=5d95b211f59e65412ba2f0c494036639
#6
@
3 months ago
Opened [PR #12397](https://github.com/WordPress/wordpress-develop/pull/12397) to address this ticket. This updates admin menu rendering so generated menu item href values use absolute URLs in the current admin context, while preserving already absolute/external URLs. Validation: - php -l src
wp-admin
menu-header.php - php -l tests
phpunit
tests
admin
menuHeader.php - php vendor
squizlabs
php_codesniffer
bin
phpcbf --standard=phpcs.xml.dist src
wp-admin
menu-header.php tests
phpunit
tests
admin
menuHeader.php - php vendor
squizlabs
php_codesniffer
bin
phpcs --standard=phpcs.xm The PR includes focused regression coverage, and its validation details are recorded in the PR description.
I picked this up because the ticket describes a concrete core behavior or edge case that remains relevant in current WordPress. The proposed change is intentionally scoped to the ticket and is submitted here for code review, with the technical discussion remaining on this ticket.
#56303 was marked as a duplicate.