|
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
|
|
|
|
|
33
|
|
|
return $methods; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns what features are available. Uses the slug of the module files. |
|
38
|
|
|
* |
|
39
|
|
|
* @return array |
|
40
|
|
|
*/ |
|
41
|
|
View Code Duplication |
public static function features_available() { |
|
42
|
|
|
$raw_modules = Jetpack::get_available_modules(); |
|
43
|
|
|
$modules = array(); |
|
44
|
|
|
foreach ( $raw_modules as $module ) { |
|
45
|
|
|
$modules[] = Jetpack::get_module_slug( $module ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $modules; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns what features are enabled. Uses the slug of the modules files. |
|
53
|
|
|
* |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
|
View Code Duplication |
public static function features_enabled() { |
|
57
|
|
|
$raw_modules = Jetpack::get_active_modules(); |
|
58
|
|
|
$modules = array(); |
|
59
|
|
|
foreach ( $raw_modules as $module ) { |
|
60
|
|
|
$modules[] = Jetpack::get_module_slug( $module ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return $modules; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Filters the result of test_connection XMLRPC method |
|
68
|
|
|
* |
|
69
|
|
|
* @return string The current Jetpack version number |
|
70
|
|
|
*/ |
|
71
|
|
|
public function test_connection() { |
|
72
|
|
|
return JETPACK__VERSION; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|