wpelevator / wp-inspector-browser-extension

MIT License
2 stars 0 forks source link

Admin link for multisite goes to root site's admin instead of site being viewed (subfolder installation) #2

Open MadtownLems opened 1 week ago

MadtownLems commented 1 week ago

If I'm viewing multisite.com/subsite/, and click the admin link, it takes me to multisite.com/wp-admin/ instead of multisite.com/subsite/wp-admin. Any way to have it to go the latter?

kasparsd commented 1 week ago

Thanks for reporting the issue @MadtownLems.

Currently, the extension simply appends the wp-admin to the hostname of the site. This works for subdomain or custom domain multisites (because WP core will redirect it to siteurl even requested from homeurl) but obviously fails with subdirectory setups.

To detect the actual WP homeurl or siteurl, one option would be to use the feed or oEmbed URLs from the <head> since they usually point to homeurl + .... However, some sites disable feeds and these embed URLs. Are they enabled for your project?

MadtownLems commented 1 week ago

We actually do strip out quite a bit of stuff like that, and I totally understand if there's not a good solution for us.

In fact, I have a little custom bookmarklet that does exactly the same thing as this extension: provides a /wp-admin/ login link to the hostname, which also fails on those subfolder sites.

I think most sites could use something like a variation of the <link rel="alternate"...Feed> tag to find the home url of the subsite.