You are here

function advagg_get_github_version_json in Advanced CSS/JS Aggregation 7.2

Get the latest version number for the remote version.

Parameters

array $library: An associative array containing all information about the library.

array $options: An associative array containing options for the version parser.

string $url: URL for the remote version to lookup.

Return value

string The latest version number as a string or 0 on failure.

4 string references to 'advagg_get_github_version_json'
advagg_font_libraries_info in advagg_font/advagg_font.module
Implements hook_libraries_info().
advagg_get_remote_libraries_version in ./advagg.module
Get the latest version number for the remote version.
advagg_mod_libraries_info in advagg_mod/advagg_mod.module
Implements hook_libraries_info().
advagg_validator_libraries_info in advagg_validator/advagg_validator.module
Implements hook_libraries_info().

File

./advagg.module, line 5616
Advanced CSS/JS aggregation module.

Code

function advagg_get_github_version_json(array $library, array $options, $url) {
  $http_options = array(
    'timeout' => 2,
  );
  $package = drupal_http_request($url, $http_options);
  if (empty($package->data)) {

    // Try again.
    $package = drupal_http_request($url, array(
      'timeout' => 5,
    ));
  }
  if (empty($package->data)) {

    // Try again but force http.
    $url = advagg_force_http_path($url);
    $package = drupal_http_request($url, $http_options);
  }
  if (!empty($package->data)) {
    $package = json_decode($package->data);
    if (isset($package->version)) {
      return (string) $package->version;
    }
  }
  return 0;
}