Skip to content

Commit

Permalink
Added link to latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
f13dev committed Jun 23, 2016
1 parent ff883e2 commit da39e13
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions github-embed.php
Expand Up @@ -325,6 +325,7 @@ private function oembed_github_repo ( $owner, $repository ) {

$repo = $this->api->get_repo ( $owner, $repository );
$commits =$this->api->get_repo_commits ( $owner, $repository );
$releases = $this->api->get_repo_releases ( $owner, $repository );

$response = new stdClass();
$response->type = 'rich';
Expand All @@ -337,6 +338,24 @@ private function oembed_github_repo ( $owner, $repository ) {
$response->html = '<div class="github-embed github-embed-repository">';
$response->html .= '<p><a href="'.esc_attr($repo->html_url).'" target="_blank"><strong>'.esc_html($repo->description)."</strong></a><br/>";
$response->html .= '<a href="'.esc_attr($repo->html_url).'" target="_blank">'.esc_html($repo->html_url)."</a><br/>";


/*
* Show the latest release if one exists, otherwise show Latest release: none.
*/
if ( $releases == null )
{
$response->html .= "Latest release: none<br />";
}
else
{
$latest_release = $this->api->get_repo_releases_latest ( $owner, $repository );
$latest_release_url = $latest_release->html_url;
$latest_release_tag = $latest_release->tag_name;
$response->html .= 'Latest release: <a href="' . $latest_release_url . '" target="_blank">' .
$latest_release_tag . '</a><br />';
}

$response->html .= '<a href="'.esc_attr($repo->html_url . '/network') . '" target="_blank">'.esc_html ( number_format_i18n ( $repo->forks_count ) ) . "</a> forks.<br/>";
$response->html .= '<a href="'.esc_attr($repo->html_url . '/stargazers') . '" target="_blank">'.esc_html ( number_format_i18n ( $repo->stargazers_count ) ) . "</a> stars.<br/>";
$response->html .= '<a href="'.esc_attr($repo->html_url . '/issues') . '" target="_blank">'.esc_html ( number_format_i18n ( $repo->open_issues_count ) ) . "</a> open issues.<br/>";
Expand Down

0 comments on commit da39e13

Please sign in to comment.