From b0c579b4048b05d68373ad92252efaa6586a3e7b Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Fri, 17 May 2019 17:03:59 +0100 Subject: [PATCH] Embed GitHub logo rather than hotlink. Also add choice (via filter) of logos. Fixes #28 --- css/github-embed.css | 12 ++++++++++-- github-embed.php | 12 ++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/css/github-embed.css b/css/github-embed.css index c0c58bc..e659d51 100644 --- a/css/github-embed.css +++ b/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; -} \ No newline at end of file +} diff --git a/github-embed.php b/github-embed.php index 7cf4c91..0e84afd 100644 --- a/github-embed.php +++ b/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 = '
'; + $logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' ); + $response->html = '
'; $response->html .= '

'; $response->html .= '' . esc_html( $repo->description ) . '
'; $response->html .= 'Contributors: '; @@ -232,7 +233,8 @@ class github_embed { $response->title = $repo->description; // @TODO This should all be templated - $response->html = '

'; + $logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' ); + $response->html = '
'; $response->html .= '

' . esc_html( $repo->description ) . '
'; $response->html .= 'Milestone: '; @@ -274,7 +276,8 @@ class github_embed { $response->title = $repo->description; // @TODO This should all be templated - $response->html = '

'; + $logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-mark' ); + $response->html = '
'; $response->html .= '

' . esc_html( $repo->description ) . '
'; $response->html .= '' . esc_html( $repo->html_url ) . '
'; $response->html .= '' . esc_html( number_format_i18n( $repo->forks_count ) ) . ' forks.
'; @@ -320,7 +323,8 @@ class github_embed { $response->title = $owner_info->name; // @TODO This should all be templated - $response->html = '

'; + $logo_class = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' ); + $response->html = '
'; $response->html .= '

' . esc_html( $owner ) . '
'; $response->html .= esc_html( number_format_i18n( $owner_info->public_repos ) ) . ' repositories, '; $response->html .= esc_html( number_format_i18n( $owner_info->followers ) ) . ' followers.

';