Last active
October 14, 2016 08:11
-
-
Save pospi/6547214 to your computer and use it in GitHub Desktop.
Premodify URLs on WPEngine to directly point to your CDN. Avoids issues some link generators have with HTTP redirects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpe_noRedirectUrl($srcURL) | |
{ | |
if (class_exists('WpeCommon')) { | |
global $wpe_netdna_domains; | |
static $cdn_domain; | |
if (!isset($cdn_domain)) { | |
$wpe_common = new WpeCommon(); | |
if ($wpe_common->is_cdn_enabled()) { | |
$cdn_domain = $wpe_common->get_cdn_domain($wpe_netdna_domains, get_bloginfo('url')); | |
} | |
} | |
if ($cdn_domain) { | |
$srcURL = preg_replace('/' . preg_quote(get_bloginfo('url'), '/') . '/', (is_ssl() ? 'https://' : 'http://') . $cdn_domain, $srcURL); | |
} | |
} | |
return $srcURL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment