Browse Source

Add stylesheet

widget
Lee Willis 12 years ago
parent
commit
8f91fe381b
  1. 3
      css/github-embed.css
  2. 21
      github-embed.php

3
css/github-embed.css

@ -0,0 +1,3 @@
.github-embed {
padding: 0.5em 2em 0.5em 4em;
}

21
github-embed.php

@ -42,13 +42,28 @@ class github_embed {
add_action ( 'init', array ( $this, 'register_oembed_handler' ) ); add_action ( 'init', array ( $this, 'register_oembed_handler' ) );
add_action ( 'init', array ( $this, 'maybe_handle_oembed' ) ); add_action ( 'init', array ( $this, 'maybe_handle_oembed' ) );
add_action ( 'wp_enqueue_scripts', array ( $this, 'enqueue_styles' ) );
// @TODO i18n // @TODO i18n
} }
/**
* Enqueue the frontend CSS
* @return void
*/
function enqueue_styles() {
error_log ( __FUNCTION__ );
wp_register_style ( 'github-embed', plugins_url(basename(dirname(__FILE__)).'/css/github-embed.css' ) );
wp_enqueue_style ( 'github-embed' );
}
/** /**
* Register the oEmbed provider, and point it at a local endpoint since github * Register the oEmbed provider, and point it at a local endpoint since github
* doesn't directly support oEmbed yet. Our local endpoint will use the github * doesn't directly support oEmbed yet. Our local endpoint will use the github
@ -181,7 +196,8 @@ class github_embed {
$response->title = $repo->description; $response->title = $repo->description;
// @TODO This should all be templated // @TODO This should all be templated
$response->html = '<p><a href="'.esc_attr($repo->html_url).'" target="_blank"><strong>'.esc_html($repo->description)."</strong></a><br/>"; $response->html = '<div class="github-embed">';
$response->html .= '<p><a href="'.esc_attr($repo->html_url).'" target="_blank"><strong>'.esc_html($repo->description)."</strong></a><br/>";
$response->html .= esc_html($repo->html_url)."<br/>"; $response->html .= esc_html($repo->html_url)."<br/>";
$response->html .= esc_html($repo->forks_count)." forks.<br/>"; $response->html .= esc_html($repo->forks_count)." forks.<br/>";
$response->html .= esc_html($repo->open_issues_count)." open issues.<br/>"; $response->html .= esc_html($repo->open_issues_count)." open issues.<br/>";
@ -210,6 +226,7 @@ class github_embed {
} }
$response->html .= '</p>'; $response->html .= '</p>';
$response->html .= '</div>';
header ( 'Content-Type: application/json' ); header ( 'Content-Type: application/json' );
echo json_encode ( $response ); echo json_encode ( $response );

Loading…
Cancel
Save