Created
August 29, 2013 17:01
-
-
Save simonwheatley/6380700 to your computer and use it in GitHub Desktop.
Get updates to Automattic code from GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Automattic Updater | |
Description: Get updates to Automattic code from GitHub | |
Version: 1.0 | |
Author: Code for the People | |
Author URI: http://codeforthepeople.com/ | |
Copyright © 2013 Code for the People Ltd | |
_____________ | |
/ ____ \ | |
_____/ \ \ \ | |
/\ \ \___\ \ | |
/ \ \ \ | |
/ / / _______\ | |
/ / / \ / | |
/ / / \ / | |
\ \ \ _____ ___\ / | |
\ \ /\ \ / \ | |
\ \ / \____\/ _____\ | |
\ \/ / / / \ | |
\ /____/ /___\ | |
\ / | |
\______________________/ | |
*/ | |
defined( 'ABSPATH' ) or die(); | |
/** | |
* [atmc_update_handler description] | |
* | |
* @author John Blackbourn | |
* @param EUAPI_Handler|null $handler [description] | |
* @param EUAPI_Item $item [description] | |
* @return EUAPI_Handler|null [description] | |
*/ | |
function atmc_update_handler( EUAPI_Handler $handler = null, EUAPI_Item $item ) { | |
$url = untrailingslashit( $item->url ); | |
if ( preg_match( '#^https://github\.com/(Automattic)/#', $url ) ) { | |
$handler = new EUAPI_Handler_GitHub( array( | |
'type' => $item->type, | |
'file' => $item->file, | |
'github_url' => $url, | |
'access_token' => get_option( 'euapi_github_access_token', null ), | |
'sslverify' => false | |
) ); | |
} | |
return $handler; | |
} | |
add_filter( 'euapi_plugin_handler', 'atmc_update_handler', 9, 2 ); | |
add_filter( 'euapi_theme_handler', 'atmc_update_handler', 9, 2 ); | |
add_action( 'plugins_loaded', function() { | |
if ( function_exists( 'euapi_flush_transients' ) ) { | |
register_activation_hook( __FILE__, 'euapi_flush_transients' ); | |
register_deactivation_hook( __FILE__, 'euapi_flush_transients' ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment