Opened 2 years ago
Last modified 2 years ago
#56302 new defect (bug)
Admin menu links have relative URLs
Reported by: | iihglobal | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-screenshots dev-feedback has-patch has-testing-info has-unit-tests |
Focuses: | administration | Cc: |
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 (6)
#2
@
2 years ago
- Component changed from Menus to Administration
- Description modified (diff)
- Summary changed from Menu link on admin side to Admin menu links have relative URLs
- Version 6.0 deleted
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.
@
2 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
@
2 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.php
page's contents remain, but the URL changes to/wp-admin/options.php/options-general.php
. - ✅ After the patch: The contents change to the
General
page's contents, and the URL is/wp-admin/options-general.php
.
Notes
- This patch is an example of one approach, but be aware that there are further changes required to the
WP_List_Tables
views links, as well as all other relative links throughout the Dashboard. I'm happy to continue this work to address the other areas, if the approach in the patch is desired. - Adding
dev-feedback
to see if this approach is desired or if there are other ideas of how to manage this throughout the Dashboard.
#4
@
2 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
#56303 was marked as a duplicate.