Can someone please tell me how to get the correct url of the page the user is on? I need to grab the url and construct a new link. Here is the issue that I am having. For example, let's say I am on http://localhost/myplugin/samplepage/?some_var=1&some_var=2
home_url() is http://localhost/myplugin $_SERVER['REQUEST_URI] is /myplugin/samplepage/?some_var=1&some_var=2
As you can see, if I do this
$url = home_url() . $_SERVER['REQUEST_URI];
The outcome will be
Notice the 'myplugin' in the url twice, which doesn't work.