Completed
Push — try/alt-xmlrpc ( 6ed61e...a3ab0c )
by
unknown
10:18
created

class.jetpack-xmlrpc-fallback.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php 
2
3
/**
4
 * A bridge between WP's built-in REST and Jetpack's XMLRPC server
5
 */
6
class Jetpack_XMLRPC_Fallback {
7
    private $xmlrpc_server;
8
9
    function init() {
10
        register_rest_route( 'jetpack/v1', '/verify_registration', array(
11
			'methods' => 'POST',
12
			'callback' => array( $this, 'verify_registration' ),
13
		) );
14
15
        // fallback for anything not yet converted
16
        register_rest_route( 'jetpack/v1', '/xmlrpc', array(
17
			'methods' => 'POST',
18
			'callback' => array( $this, 'xmlrpc_fallback' ),
19
		) );
20
    }
21
22
    function verify_registration( $request ) {
23
        $this->load_xmlrpc();
24
		return $this->xmlrpc_server->verify_registration( array( $request['secret_1'], $request['state'] ) );
25
	}
26
27
    // allow invocation of Jetpack XMLRPC, and a handful of core XMLRPC methods, over REST
28
    // does NOT allow random XMLRPC requests
29
    function xmlrpc_fallback( $request ) {
30
        $this->load_xmlrpc();
31
        $methods = $this->xmlrpc->xmlrpc_methods();
0 ignored issues
show
The property xmlrpc does not seem to exist. Did you mean xmlrpc_server?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
32
        error_log("xmlrpc fallback");
33
        error_log(print_r($methods,1));
34
    }
35
36
    private function load_xmlrpc() {
37
        if ( ! $this->xmlrpc_server ) {
38
            require_once JETPACK__PLUGIN_DIR . 'class.jetpack-xmlrpc-server.php';
39
            $this->xmlrpc_server = new Jetpack_XMLRPC_Server();
40
        }
41
    }
42
}