Skip to content

Instantly share code, notes, and snippets.

@lasida
Last active September 11, 2021 10:26
Show Gist options
  • Save lasida/4d1c03cb38b767a282a5381d140279f6 to your computer and use it in GitHub Desktop.
Save lasida/4d1c03cb38b767a282a5381d140279f6 to your computer and use it in GitHub Desktop.
$user = "lsdplugins";
$repo = "lsddonation-mynotif";
$api = " https://api.github.com/repos/$user/$repo/releases";
$headers = [
'Accept' => 'application/vnd.github.v3+json',
];
$payload = [
'timeout' => 30,
'headers' => $headers,
'sslverify' => false,
];
$request = wp_remote_get($api, $payload);
$response = json_decode(wp_remote_retrieve_body($request));
$github_latest_version = (string) $response[0]->tag_name; // 1.0.0
$github_latest_zip = array_column($response, 'zipball_url')[0]; // https://api.github.com/repos/lsdplugins/lsddonation-mynotif/zipball/1.1.0
var_dump( $github_latest_version, $github_latest_zip );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment