'GET', 'callback' => array( $this, 'handle' ), 'permission_callback' => '__return_true', 'args' => array( 'challenge' => array( 'type' => 'string', 'required' => true, 'pattern' => '^[a-f0-9]{32}$', ), ), ) ); } /** * Handle the request. * * @param \WP_REST_Request $request Request. * @return \WP_REST_Response */ public function handle( $request ) { $signature = ( new Connection( Connection::client() ) )->sign_challenge( (string) $request->get_param( 'challenge' ) ); if ( null === $signature ) { return new \WP_REST_Response( array( 'error' => 'not_connecting' ), 404 ); } $response = new \WP_REST_Response( array( 'signature' => $signature ), 200 ); $response->header( 'Cache-Control', 'no-store' ); return $response; } }