Skip to content

Instantly share code, notes, and snippets.

@georgestephanis
Created July 28, 2015 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgestephanis/f79bae84970685fd591f to your computer and use it in GitHub Desktop.
Save georgestephanis/f79bae84970685fd591f to your computer and use it in GitHub Desktop.
function is_staging_site_for_domain( $domain, $staging ) {
$parsed_domain = parse_url( $domain );
$parsed_staging = parse_url( $staging );
$preg_quoted_domain_host = preg_quote( $domain['host'], '/' );
// If it's a local. dev. preprod. or staging. subdomain…
if ( preg_match( '/(local|dev|preprod|staging)\.' . $preg_quoted_domain_host . '/i', $parsed_staging['host'] ) ) {
return true;
}
if ( preg_match( '/' . $preg_quoted_domain_host . '\.wpstagecoach.com/i', $parsed_staging['host'] ) ) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment