| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | /* |
| 4 | 4 | Plugin Name: Github Embed |
| 5 | 5 | Plugin URI: http://www.leewillis.co.uk/wordpress-plugins |
| 6 | 6 | Description: Paste the URL to a Github project into your posts or pages, and have the project information pulled in and displayed automatically |
| 7 | -Version: 1.0 | |
| 7 | +Version: 1.1 | |
| 8 | 8 | Author: Lee Willis |
| 9 | 9 | Author URI: http://www.leewillis.co.uk/ |
| 10 | 10 | */ |
| 11 | 11 | |
| @@ -41,11 +41,25 @@ | ||
| 41 | 41 | public function __construct() { |
| 42 | 42 | |
| 43 | 43 | add_action ( 'init', array ( $this, 'register_oembed_handler' ) ); |
| 44 | 44 | add_action ( 'init', array ( $this, 'maybe_handle_oembed' ) ); |
| 45 | + add_action ( 'wp_enqueue_scripts', array ( $this, 'enqueue_styles' ) ); | |
| 46 | + | |
| 47 | + // @TODO i18n | |
| 45 | 48 | |
| 46 | - // @TODO i18n | |
| 49 | + } | |
| 47 | 50 | |
| 51 | + | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Enqueue the frontend CSS | |
| 55 | + * @return void | |
| 56 | + */ | |
| 57 | + function enqueue_styles() { | |
| 58 | + | |
| 59 | + wp_register_style ( 'github-embed', plugins_url(basename(dirname(__FILE__)).'/css/github-embed.css' ) ); | |
| 60 | + wp_enqueue_style ( 'github-embed' ); | |
| 61 | + | |
| 48 | 62 | } |
| 49 | 63 | |
| 50 | 64 | |
| 51 | 65 | |
| @@ -180,10 +194,11 @@ | ||
| 180 | 194 | $response->version = '1.0'; |
| 181 | 195 | $response->title = $repo->description; |
| 182 | 196 | |
| 183 | 197 | // @TODO This should all be templated |
| 184 | - $response->html = '<p><a href="'.esc_attr($repo->html_url).'" target="_blank"><strong>'.esc_html($repo->description)."</strong></a><br/>"; | |
| 185 | - $response->html .= esc_html($repo->html_url)."<br/>"; | |
| 198 | + $response->html = '<div class="github-embed github-embed-repository">'; | |
| 199 | + $response->html .= '<p><a href="'.esc_attr($repo->html_url).'" target="_blank"><strong>'.esc_html($repo->description)."</strong></a><br/>"; | |
| 200 | + $response->html .= '<a href="'.esc_attr($repo->html_url).'" target="_blank">'.esc_html($repo->html_url)."</a><br/>"; | |
| 186 | 201 | $response->html .= esc_html($repo->forks_count)." forks.<br/>"; |
| 187 | 202 | $response->html .= esc_html($repo->open_issues_count)." open issues.<br/>"; |
| 188 | 203 | |
| 189 | 204 | if ( count ( $commits ) ) { |
| @@ -209,8 +224,9 @@ | ||
| 209 | 224 | $response->html .= '</ul>'; |
| 210 | 225 | |
| 211 | 226 | } |
| 212 | 227 | $response->html .= '</p>'; |
| 228 | + $response->html .= '</div>'; | |
| 213 | 229 | |
| 214 | 230 | header ( 'Content-Type: application/json' ); |
| 215 | 231 | echo json_encode ( $response ); |
| 216 | 232 | die(); |
| @@ -246,11 +262,13 @@ | ||
| 246 | 262 | $response->version = '1.0'; |
| 247 | 263 | $response->title = $owner_info->name; |
| 248 | 264 | |
| 249 | 265 | // @TODO This should all be templated |
| 250 | - $response->html = '<p><a href="https://github.com/'.esc_attr($owner).'" target="_blank"><strong>'.esc_html($owner)."</strong></a><br/>"; | |
| 266 | + $response->html = '<div class="github-embed github-embed-user">'; | |
| 267 | + $response->html .= '<p><a href="https://github.com/'.esc_attr($owner).'" target="_blank"><strong>'.esc_html($owner)."</strong></a><br/>"; | |
| 251 | 268 | $response->html .= esc_html($owner_info->public_repos).' repositories, '; |
| 252 | 269 | $response->html .= esc_html($owner_info->followers).' followers.</p>'; |
| 270 | + $response->html .= '</div>'; | |
| 253 | 271 | |
| 254 | 272 | header ( 'Content-Type: application/json' ); |
| 255 | 273 | echo json_encode ( $response ); |
| 256 | 274 | die(); |