Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/Dropbox2/OAuth/Consumer
File: WordPress.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* OAuth consumer using the WordPress API
[3] Fix | Delete
* @author David Anderson <david@updraftplus.com>
[4] Fix | Delete
* @link https://github.com/DavidAnderson684/Dropbox
[5] Fix | Delete
* @package Dropbox\OAuth
[6] Fix | Delete
* @subpackage Consumer
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class Dropbox_ConsumerWordPress extends Dropbox_ConsumerAbstract
[10] Fix | Delete
{
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Set properties and begin authentication
[14] Fix | Delete
* @param string $key
[15] Fix | Delete
* @param string $secret
[16] Fix | Delete
* @param \Dropbox\OAuth\Consumer\StorageInterface $storage
[17] Fix | Delete
* @param string $callback
[18] Fix | Delete
*/
[19] Fix | Delete
public function __construct($key, $secret, Dropbox_StorageInterface $storage, $callback = null)
[20] Fix | Delete
{
[21] Fix | Delete
// Check we are in a WordPress environment
[22] Fix | Delete
if (!defined('ABSPATH')) {
[23] Fix | Delete
throw new Dropbox_Exception('The WordPress OAuth consumer requires a WordPress environment');
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
$this->consumerKey = $key;
[27] Fix | Delete
$this->consumerSecret = $secret;
[28] Fix | Delete
$this->storage = $storage;
[29] Fix | Delete
$this->callback = $callback;
[30] Fix | Delete
$this->authenticate();
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Execute an API call
[35] Fix | Delete
* @param string $method The HTTP method
[36] Fix | Delete
* @param string $url The API endpoint
[37] Fix | Delete
* @param string $call The API method to call
[38] Fix | Delete
* @param array $additional Additional parameters
[39] Fix | Delete
* @return array
[40] Fix | Delete
*/
[41] Fix | Delete
public function fetch($method, $url, $call, array $additional = array())
[42] Fix | Delete
{
[43] Fix | Delete
// Get the signed request URL
[44] Fix | Delete
$request = $this->getSignedRequest($method, $url, $call, $additional);
[45] Fix | Delete
if ($method == 'GET') {
[46] Fix | Delete
$args = array ( );
[47] Fix | Delete
$response = wp_remote_get($request['url'], $args);
[48] Fix | Delete
$this->outFile = null;
[49] Fix | Delete
} elseif ($method == 'POST') {
[50] Fix | Delete
$args = array( 'body' => $request['postfields'] );
[51] Fix | Delete
$response = wp_remote_post($request['url'], $args );
[52] Fix | Delete
} elseif ($method == 'PUT' && $this->inFile) {
[53] Fix | Delete
return new WP_Error('unsupported', "WordPress does not have a native HTTP PUT function");
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
// If the response body is not a JSON encoded string
[57] Fix | Delete
// we'll return the entire response body
[58] Fix | Delete
// Important to do this first, as the next section relies on the decoding having taken place
[59] Fix | Delete
if (!$body = json_decode(wp_remote_retrieve_body($response))) {
[60] Fix | Delete
$body = wp_remote_retrieve_body($response);
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
// Check if an error occurred and throw an Exception. This is part of the authentication process - don't modify.
[64] Fix | Delete
if (!empty($body->error)) {
[65] Fix | Delete
$message = $body->error . ' (Status Code: ' . wp_remote_retrieve_response_code($response) . ')';
[66] Fix | Delete
throw new Dropbox_Exception($message);
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if (is_wp_error($response)) {
[70] Fix | Delete
$message = $response->get_error_message();
[71] Fix | Delete
throw new Dropbox_Exception($message);
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$results = array ( 'body' => $body, 'code' => wp_remote_retrieve_response_code($response), 'headers' => $response['headers'] );
[75] Fix | Delete
return $results;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function