Found $_SERVER in the file

WP requirement of ThemeForest and found out you need to use the Envato Theme Check plugin.

It is a really wrong way to use $_SERVER. You can alternatively use the $wp global to get the current URL – it’s the same thing in the end though.

First, need to declare as global variable $wp.use following this

 global $wp

Then, add this code in your file, then you will get the current URL in the $url variable for this example:

$url = home_url(add_query_arg(array(), $wp->request));