YahnisElsts/wp-update-server

Getting the request url

Opened this issue · 1 comments

I need request url for check license. I can get url with $queryArgs[ 'site_url' ] = home_url(); but, user can change it by editing plugin file. Is possible to get request url to better?

As an alternative to query arguments, you can extract the site URL from the User-Agent HTTP header. WordPress automatically sets the user agent to something like this: WordPress/4.8; http://siteurl.com. The update server parses the header and stores the URL in the wpSiteUrl field of the current Wpup_Request instance. This means that if you're overriding one of the server methods that get a $request argument, you can get the URL from $request->wpSiteUrl.

However, it's possible to change the WordPress User-Agent with plugins, so it's not 100% reliable either. Some security-oriented plugins automatically remove the header or replace it with something generic.

As far as I know, there's no foolproof way to get the site URL. You could try using the IP address for verification, but even that can change occasionally.