Browse Source

Embed GitHub logo rather than hotlink.

Also add choice (via filter) of logos. Fixes #28
widget
Lee Willis 6 years ago
parent
commit
b0c579b404
  1. 12
      css/github-embed.css
  2. 12
      github-embed.php

12
css/github-embed.css

@ -5,7 +5,7 @@
width: 80%;
margin: auto;
margin-bottom: 1em;
background-image: url('https://github.com/github/media/raw/master/octocats/blacktocat-32.png');
background-image: url('../img/github-logos/mark.png');
background-repeat: no-repeat;
background-position: 1em 1em;
-webkit-box-shadow: 2px 2px 2px #ddd;
@ -13,6 +13,14 @@
box-shadow: 2px 2px 2px #ddd;
}
.github-embed.github-logo-octocat {
background-image: url('../img/github-logos/octocat.png');
}
.github-embed.github-logo-mark {
background-image: url('../img/github-logos/mark.png');
}
li.github-repo-contributor {
clear: both;
display: block;
@ -22,4 +30,4 @@ li.github-repo-contributor {
float: left;
margin-right: 1em;
margin-bottom: 0.5em;
}
}

12
github-embed.php

@ -195,7 +195,8 @@ class github_embed {
$gravatar_size = apply_filters( 'github_oembed_gravatar_size', 64 );
// @TODO This should all be templated
$response->html = '<div class="github-embed github-embed-repo-contributors">';
$logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' );
$response->html = '<div class="github-embed github-embed-repo-contributors ' . $logo_class . '">';
$response->html .= '<p><a href="' . esc_attr( $repo->html_url ) . '" target="_blank">';
$response->html .= '<strong>' . esc_html( $repo->description ) . '</strong></a><br/>';
$response->html .= '<span class="github-heading">Contributors: </span>';
@ -232,7 +233,8 @@ class github_embed {
$response->title = $repo->description;
// @TODO This should all be templated
$response->html = '<div class="github-embed github-embed-milestone-summary">';
$logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' );
$response->html = '<div class="github-embed github-embed-milestone-summary ' . $logo_class . '">';
$response->html .= '<p><a href="' . esc_attr( $repo->html_url ) . '" target="_blank"><strong>' . esc_html( $repo->description ) . '</strong></a><br/>';
$response->html .= '<span class="github-heading">Milestone: </span>';
@ -274,7 +276,8 @@ class github_embed {
$response->title = $repo->description;
// @TODO This should all be templated
$response->html = '<div class="github-embed github-embed-repository">';
$logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-mark' );
$response->html = '<div class="github-embed github-embed-repository ' . $logo_class . '">';
$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/>';
$response->html .= '<a href="' . esc_attr( $repo->html_url . '/network' ) . '" target="_blank">' . esc_html( number_format_i18n( $repo->forks_count ) ) . '</a> forks.<br/>';
@ -320,7 +323,8 @@ class github_embed {
$response->title = $owner_info->name;
// @TODO This should all be templated
$response->html = '<div class="github-embed github-embed-user">';
$logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' );
$response->html = '<div class="github-embed github-embed-user ' . $logo_class . '">';
$response->html .= '<p><a href="https://github.com/' . esc_attr( $owner ) . '" target="_blank"><strong>' . esc_html( $owner ) . '</strong></a><br/>';
$response->html .= esc_html( number_format_i18n( $owner_info->public_repos ) ) . ' repositories, ';
$response->html .= esc_html( number_format_i18n( $owner_info->followers ) ) . ' followers.</p>';

Loading…
Cancel
Save