summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2016-06-22 20:52:57 -0400
committerAnthony G. Basile <blueness@gentoo.org>2016-06-22 20:52:57 -0400
commitf7f019456122473c53bd3661b910e09fe4fbc92a (patch)
tree7349a3b80b9ea5e7bfbc9039926dfba34eba8bfb /plugins/jetpack/class.jetpack-xmlrpc-server.php
parentUpdate plugin wordpress-mobile-pack to 2.2.4 (diff)
downloadblogs-gentoo-f7f019456122473c53bd3661b910e09fe4fbc92a.tar.gz
blogs-gentoo-f7f019456122473c53bd3661b910e09fe4fbc92a.tar.bz2
blogs-gentoo-f7f019456122473c53bd3661b910e09fe4fbc92a.zip
Update plugin jecpack to 4.0.4
Diffstat (limited to 'plugins/jetpack/class.jetpack-xmlrpc-server.php')
-rw-r--r--plugins/jetpack/class.jetpack-xmlrpc-server.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/plugins/jetpack/class.jetpack-xmlrpc-server.php b/plugins/jetpack/class.jetpack-xmlrpc-server.php
index d7b22547..9ecad85b 100644
--- a/plugins/jetpack/class.jetpack-xmlrpc-server.php
+++ b/plugins/jetpack/class.jetpack-xmlrpc-server.php
@@ -75,7 +75,27 @@ class Jetpack_XMLRPC_Server {
}
function authorize_xmlrpc_methods() {
- return array( 'jetpack.remoteAuthorize' => array( $this, 'remote_authorize' ) );
+ return array(
+ 'jetpack.remoteAuthorize' => array( $this, 'remote_authorize' ),
+ 'jetpack.activateManage' => array( $this, 'activate_manage' ),
+ );
+ }
+
+ function activate_manage( $request ) {
+ foreach( array( 'secret', 'state' ) as $required ) {
+ if ( ! isset( $request[ $required ] ) || empty( $request[ $required ] ) ) {
+ return $this->error( new Jetpack_Error( 'missing_parameter', 'One or more parameters is missing from the request.', 400 ) );
+ }
+ }
+ $verified = $this->verify_action( array( 'activate_manage', $request['secret'], $request['state'] ) );
+ if ( is_a( $verified, 'IXR_Error' ) ) {
+ return $verified;
+ }
+ $activated = Jetpack::activate_module( 'manage', false, false );
+ if ( false === $activated || ! Jetpack::is_module_active( 'manage' ) ) {
+ return $this->error( new Jetpack_Error( 'activation_error', 'There was an error while activating the module.', 500 ) );
+ }
+ return 'active';
}
function remote_authorize( $request ) {
@@ -107,8 +127,14 @@ class Jetpack_XMLRPC_Server {
if ( is_wp_error( $result ) ) {
return $this->error( $result );
}
-
- return $result;
+ // Creates a new secret, allowing someone to activate the manage module for up to 1 day after authorization.
+ $secrets = Jetpack::init()->generate_secrets( 'activate_manage', DAY_IN_SECONDS );
+ @list( $secret ) = explode( ':', $secrets );
+ $response = array(
+ 'result' => $result,
+ 'activate_manage' => $secret,
+ );
+ return $response;
}
/**