I have this simple method which checks if a url is for part of my admin area.
protected function is_admin_url ( $url ) {
$parts = parse_url( $url );
if ( !empty($parts['path']) ) {
$steps = explode('/', $parts['path']);
if ( $steps[1] == $this->slug ) // $steps[0] will always be empty
return true;
}
return false;
}
It should return true
for any url in the form http://example.com/slug/foo?bar=baz
The problem I'm having is that while developing on my local machine (using WAMP) all urls are in the form http://localhost/example.com/slug/foo?bar=baz
. This of course breaks the method since the domain is now part of the path.
Hard coding the array index is bound to lead to bugs. Is there any conditional statement I can add in to handle this?
I should also note, this is part of a plugin for WordPress. The site url is not known.