Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the request url #68

Open
bilalmalkoc opened this issue Nov 24, 2018 · 1 comment
Open

Getting the request url #68

bilalmalkoc opened this issue Nov 24, 2018 · 1 comment
Labels

Comments

@bilalmalkoc
Copy link

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?

@YahnisElsts
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants