Make WordPress Core

Opened 2 years ago

Last modified 21 months ago

#56302 new defect (bug)

Admin menu links have relative URLs

Reported by: iihglobal's profile 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 sabernhardt)

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)

Settings-menu-29-July-2022.mp4 (4.1 MB) - added by sabernhardt 2 years ago.
56302.diff (3.5 KB) - added by costdev 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."

Change History (6)

#1 @Tyrannous
2 years ago

#56303 was marked as a duplicate.

#2 @sabernhardt
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.

@costdev
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 @costdev
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

  1. Navigate to /wp-admin/options.php/ - Note the trailing slash.
  2. Click General.
  3. 🐞 The contents do not change, but the URL changes to /wp-admin/options.php/options-general.php.
  4. Apply 56302.diff.
  5. Navigate to /wp-admin/options.php/ - Note the trailing slash.
  6. 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.
Version 0, edited 2 years ago by costdev (next)

#4 @sumitsingh
21 months 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

Note: See TracTickets for help on using tickets.