1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Jetpack XMLRPC Methods. |
4
|
|
|
* |
5
|
|
|
* Registers the Jetpack specific XMLRPC methods |
6
|
|
|
* |
7
|
|
|
* @package jetpack |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* XMLRPC Methods registration and callbacks |
12
|
|
|
*/ |
13
|
|
|
class Jetpack_XMLRPC_Methods { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Initialize the main hooks. |
17
|
|
|
*/ |
18
|
|
|
public static function init() { |
19
|
|
|
add_filter( 'jetpack_xmlrpc_unauthenticated_methods', array( __CLASS__, 'xmlrpc_methods' ) ); |
20
|
|
|
add_filter( 'jetpack_xmlrpc_test_connection_response', array( __CLASS__, 'test_connection' ) ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Adds Jetpack specific methods to the methods added by the Connection package. |
25
|
|
|
* |
26
|
|
|
* @param array $methods Methods added by the Connection package. |
27
|
|
|
*/ |
28
|
|
|
public function xmlrpc_methods( $methods ) { |
29
|
|
|
|
30
|
|
|
$methods['jetpack.featuresAvailable'] = array( __CLASS__, 'features_available' ); |
31
|
|
|
$methods['jetpack.featuresEnabled'] = array( __CLASS__, 'features_enabled' ); |
32
|
|
|
$methods['jetpack.disconnectBlog'] = array( __CLASS__, 'disconnect_blog' ); |
33
|
|
|
|
34
|
|
|
return $methods; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns what features are available. Uses the slug of the module files. |
39
|
|
|
* |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
View Code Duplication |
public static function features_available() { |
43
|
|
|
$raw_modules = Jetpack::get_available_modules(); |
44
|
|
|
$modules = array(); |
45
|
|
|
foreach ( $raw_modules as $module ) { |
46
|
|
|
$modules[] = Jetpack::get_module_slug( $module ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return $modules; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Returns what features are enabled. Uses the slug of the modules files. |
54
|
|
|
* |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
View Code Duplication |
public static function features_enabled() { |
58
|
|
|
$raw_modules = Jetpack::get_active_modules(); |
59
|
|
|
$modules = array(); |
60
|
|
|
foreach ( $raw_modules as $module ) { |
61
|
|
|
$modules[] = Jetpack::get_module_slug( $module ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $modules; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Filters the result of test_connection XMLRPC method |
69
|
|
|
* |
70
|
|
|
* @return string The current Jetpack version number |
71
|
|
|
*/ |
72
|
|
|
public function test_connection() { |
73
|
|
|
return JETPACK__VERSION; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Disconnect this blog from the connected wordpress.com account |
78
|
|
|
* |
79
|
|
|
* @return boolean |
80
|
|
|
*/ |
81
|
|
|
public function disconnect_blog() { |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Fired when we want to log an event to the Jetpack event log. |
85
|
|
|
* |
86
|
|
|
* @since 7.7.0 |
87
|
|
|
* |
88
|
|
|
* @param string $code Unique name for the event. |
89
|
|
|
* @param string $data Optional data about the event. |
90
|
|
|
*/ |
91
|
|
|
do_action( 'jetpack_event_log', 'disconnect' ); |
92
|
|
|
Jetpack::disconnect(); |
93
|
|
|
|
94
|
|
|
return true; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|