| @@ -1,16 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: Github Embed |
| 4 | -Plugin URI: http://www.leewillis.co.uk/wordpress-plugins | |
| 4 | +Plugin URI: https://wordpress.org/plugins/github-embed/ | |
| 5 | 5 | Description: Paste the URL to a Github project into your posts or pages, and have the project information pulled in and displayed automatically |
| 6 | -Version: 1.9 | |
| 7 | -Author: Lee Willis | |
| 8 | -Author URI: http://www.leewillis.co.uk/ | |
| 6 | +Version: 2.2.0 | |
| 7 | +Author: Ademti Software Ltd. | |
| 8 | +Author URI: https://www.ademti-software.co.uk/ | |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * Copyright (c) 2013-2020 Lee Willis. All rights reserved. | |
| 12 | + * Copyright (c) 2013-2025 Ademti Software. All rights reserved. | |
| 13 | 13 | * |
| 14 | 14 | * Released under the GPL license v2 |
| 15 | 15 | * https://www.gnu.org/licenses/gpl-2.0.en.html |
| 16 | 16 | * |
| @@ -58,9 +58,9 @@ | ||
| 58 | 58 | /** |
| 59 | 59 | * Make sure we have a scheduled event set to clear down the oEmbed cache until |
| 60 | 60 | * WordPress supports cache_age in oEmbed responses. |
| 61 | 61 | */ |
| 62 | - function schedule_expiry() { | |
| 62 | + public function schedule_expiry() { | |
| 63 | 63 | if ( ! wp_next_scheduled( 'github_embed_cron' ) ) { |
| 64 | 64 | $frequency = apply_filters( 'github_embed_cache_frequency', 'daily' ); |
| 65 | 65 | wp_schedule_event( time(), $frequency, 'github_embed_cron' ); |
| 66 | 66 | } |
| @@ -70,9 +70,9 @@ | ||
| 70 | 70 | * Expire old oEmbeds. |
| 71 | 71 | * Note: This is a bit sledgehammer-to-crack-a-nut hence why I'm only running it |
| 72 | 72 | * daily. Ideally WP should honour cache_age in oEmbed responses properly |
| 73 | 73 | */ |
| 74 | - function cron() { | |
| 74 | + public function cron() { | |
| 75 | 75 | global $wpdb, $table_prefix; |
| 76 | 76 | $sql = "DELETE |
| 77 | 77 | FROM {$table_prefix}postmeta |
| 78 | 78 | WHERE meta_key LIKE '_oembed_%'"; |
| @@ -82,9 +82,9 @@ | ||
| 82 | 82 | /** |
| 83 | 83 | * Enqueue the frontend CSS |
| 84 | 84 | * @return void |
| 85 | 85 | */ |
| 86 | - function enqueue_styles() { | |
| 86 | + public function enqueue_styles() { | |
| 87 | 87 | wp_register_style( 'github-embed', plugins_url( basename( dirname( __FILE__ ) ) . '/css/github-embed.css' ) ); |
| 88 | 88 | wp_enqueue_style( 'github-embed' ); |
| 89 | 89 | } |
| 90 | 90 | |
| @@ -187,9 +187,9 @@ | ||
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | 189 | private function process_template( $template, $data ) { |
| 190 | 190 | ob_start(); |
| 191 | - if ( ! locate_template( 'wp-github-oembed/' . $template, true ) ) { | |
| 191 | + if ( ! locate_template( 'wp-github-oembed/' . $template, true, false, ['data' => $data] ) ) { | |
| 192 | 192 | require_once 'templates/' . $template; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | return ob_get_clean(); |
| @@ -201,13 +201,14 @@ | ||
| 201 | 201 | * @param string $owner The owner of the repository |
| 202 | 202 | * @param string $repository The repository name |
| 203 | 203 | */ |
| 204 | 204 | private function oembed_github_repo_contributors( $owner, $repository ) { |
| 205 | - $data = []; | |
| 206 | - $data['repo'] = $this->api->get_repo( $owner, $repository ); | |
| 207 | - $data['contributors'] = $this->api->get_repo_contributors( $owner, $repository ); | |
| 208 | - $data['gravatar_size'] = apply_filters( 'github_oembed_gravatar_size', 64 ); | |
| 209 | - $data['logo_class'] = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' ); | |
| 205 | + $data = []; | |
| 206 | + $data['repo'] = $this->api->get_repo( $owner, $repository ); | |
| 207 | + $data['contributors'] = $this->api->get_repo_contributors( $owner, $repository ); | |
| 208 | + $data['gravatar_size'] = apply_filters( 'github_oembed_gravatar_size', 64 ); | |
| 209 | + $data['logo_class'] = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-octocat' ); | |
| 210 | + $data['details_expanded'] = apply_filters( 'wp_github_oembed_contributor_details_expanded', true ); | |
| 210 | 211 | |
| 211 | 212 | $response = new stdClass(); |
| 212 | 213 | $response->type = 'rich'; |
| 213 | 214 | $response->width = '10'; |
| @@ -251,15 +252,16 @@ | ||
| 251 | 252 | * Retrieve the information from github for a repo, and |
| 252 | 253 | * output it as an oembed response |
| 253 | 254 | */ |
| 254 | 255 | private function oembed_github_repo( $owner, $repository ) { |
| 255 | - $data = [ | |
| 256 | - 'owner_slug' => $owner, | |
| 257 | - 'repo_slug' => $repository, | |
| 256 | + $data = [ | |
| 257 | + 'owner_slug' => $owner, | |
| 258 | + 'repo_slug' => $repository, | |
| 258 | 259 | ]; |
| 259 | - $data['repo'] = $this->api->get_repo( $owner, $repository ); | |
| 260 | - $data['commits'] = $this->api->get_repo_commits( $owner, $repository ); | |
| 261 | - $data['logo_class'] = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-mark' ); | |
| 260 | + $data['repo'] = $this->api->get_repo( $owner, $repository ); | |
| 261 | + $data['commits'] = $this->api->get_repo_commits( $owner, $repository ); | |
| 262 | + $data['logo_class'] = apply_filters( 'wp_github_oembed_logo_class', 'github-logo-mark' ); | |
| 263 | + $data['details_expanded'] = apply_filters( 'wp_github_oembed_repository_commit_details_expanded', true ); | |
| 262 | 264 | |
| 263 | 265 | $response = new stdClass(); |
| 264 | 266 | $response->type = 'rich'; |
| 265 | 267 | $response->width = '10'; |