mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10390] Improve the jQuery CDN url generation function
Per p's comments, return the remote url from a variable instead of using multiple returns. Also put the logic for creating Google's version on its own line, and count the version number's dots instead of length so it will be less likely to break if jQuery goes to version 1.10. PHPBB3-10390
This commit is contained in:
parent
39840ef36d
commit
abb0f3f96d
1 changed files with 7 additions and 4 deletions
|
@ -4781,18 +4781,21 @@ function remote_jquery_url($host)
|
||||||
switch($host)
|
switch($host)
|
||||||
{
|
{
|
||||||
case 'google':
|
case 'google':
|
||||||
// Google uses a 1.5.0, 1.5.1 format (it is always a three numbered version)
|
// Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases)
|
||||||
return '//ajax.googleapis.com/ajax/libs/jquery/' . ((strlen(JQUERY_VERSION) == 3) ? JQUERY_VERSION . '.0' : JQUERY_VERSION) . '/jquery.min.js';
|
$version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION;
|
||||||
|
// HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS
|
||||||
|
$url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'microsoft':
|
case 'microsoft':
|
||||||
// Microsoft uses a 1.5, 1.5.1 format
|
// Microsoft uses a 1.5, 1.5.1 format
|
||||||
return 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js';
|
$url = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'jquery':
|
case 'jquery':
|
||||||
// jQuery uses a 1.5, 1.5.1 format
|
// jQuery uses a 1.5, 1.5.1 format
|
||||||
return 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js';
|
$url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue