forked from Automattic/babble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-updates.php
57 lines (47 loc) · 1.6 KB
/
class-updates.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Class for providing updates to Babble via GitHub rather than wordpress.org
*
* @package Babble
* @since 1.4.1
*/
class Babble_Updates extends Babble_Plugin {
public function __construct() {
$this->setup( 'babble-updates', 'plugin' );
$this->add_action( 'plugins_loaded' );
$this->add_filter( 'euapi_plugin_handler', null, 10, 2 );
}
/**
* Include the EUAPI if it's not already present.
*/
public function plugins_loaded() {
$dir = dirname( __FILE__ );
if ( !class_exists( 'EUAPI' ) ) {
include_once $dir . '/external-update-api/external-update-api.php';
}
register_activation_hook( $dir . '/babble.php', 'euapi_flush_transients' );
register_deactivation_hook( $dir . '/babble.php', 'euapi_flush_transients' );
}
/**
* Hooks into the EUAPI update mechanism and tells it to fetch Babble updates from GitHub.
*
* @param EUAPI_Handler|null $handler Usually null. Can be an EUAPI_Handler object if one has been set.
* @param EUAPI_Item $item An EUAPI_Item for the current plugin.
* @return EUAPI_Handler|null An EUAPI_Handler if we're overriding updates for this plugin, null if not.
*/
public function euapi_plugin_handler( EUAPI_Handler $handler = null, EUAPI_Item $item ) {
if ( 'http://babbleplugin.com/' == $item->url ) {
$handler = new EUAPI_Handler_GitHub( array(
'type' => $item->type,
'file' => $item->file,
'github_url' => 'https://github.com/cftp/babble',
'http' => array(
'sslverify' => false,
),
) );
}
return $handler;
}
}
global $bbl_updates;
$bbl_updates = new Babble_Updates;