admin管理员组文章数量:1384701
How can I check if CDN link is alive from function.php file on wp_enqueue section?
E.g. I have jQuery CDN and I have downloaded jQuery on local.
How can I test before mount theme (WordPress site) is CDN alive, if it is not, enqueue my local file?
Maybe test headers from request and status code?
$ch = curl_init('.5.0.min.js');
curl_exec($ch);
if (!curl_errno($ch)) {
switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
case 304:
case 200: # OK
wp_register_script ( 'latest-jquery', '.5.0.min.js' );
break;
default:
wp_register_script ( 'latest-jquery', get_template_directory_uri() . '/js/jquery-3.5.0.min.js.js' );
}
}
curl_close($ch);
本文标签: theme developmentTest CDN link from functionphp or wpenqueuescriptstyle
版权声明:本文标题:theme development - Test CDN link from function.php or wp_enqueue_scriptstyle? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744538156a2611440.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论