Skip to content

Commit

Permalink
Merge pull request #363 from ONLYOFFICE-PLUGINS/master
Browse files Browse the repository at this point in the history
Update wordpress plugin
  • Loading branch information
K0R0L authored Nov 5, 2024
2 parents 1eeb507 + ac6484f commit 93f92d6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sdkjs-plugins/content/wordpress/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"guid" : "asc.{0847b6a4-b007-11e7-abc4-cec278b6b50a}",
"baseUrl" : "",
"version" : "1.0.0",
"version" : "1.0.1",
"variations" : [
{
"description": "Publish articles directly from the document editor on your WordPress website (compatible with ONLYOFFICE cloud).",
Expand Down
12 changes: 9 additions & 3 deletions sdkjs-plugins/content/wordpress/scripts/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
(function (window, undefined) {
var wordpress = null;
var post = null;
var urlProxy = 'https://plugins-services.onlyoffice.com/proxy';

OAuthError = function(error, ttt) {
console.log(arguments);
Expand Down Expand Up @@ -57,9 +58,14 @@
var data = 'code=' + sCode + '&client_id=' + clientID + '&client_secret=' + clientSecret + '&redirect_uri=' + redirectUrl + '&grant_type=authorization_code';
var oBlogInfo = null;
jQuery.ajax( {
url: 'https://onlyoffice-proxy.herokuapp.com/https://public-api.wordpress.com/oauth2/token',
type: 'POST',
data: data,
method: 'POST',
contentType: "text/plain",
data: JSON.stringify({
"data": data,
"method": "POST",
"target": 'https://public-api.wordpress.com/oauth2/token'
}),
url: urlProxy,
success: function( response ) {
document.cookie = "mendToken=" + response.access_token + "; max-age=43200";
wordpress = new WordpressHelper(response.access_token);
Expand Down
24 changes: 12 additions & 12 deletions sdkjs-plugins/content/wordpress/scripts/wordpresshelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/

var urlProxy = 'https://plugins-services.onlyoffice.com/proxy';
var WordpressMeInfoUrl = "https://public-api.wordpress.com/rest/v1/me",
WordpressSites = "https://public-api.wordpress.com/rest/v1.2/sites/",
CodeUrl = "https://public-api.wordpress.com/oauth2/authorize",
Expand All @@ -29,23 +30,22 @@
};

async function PerformRequest(sUrl, sMethod, oHeaders, sData) {
var oParams = {};
if (oHeaders.length !== 0)
oParams['headers'] = oHeaders;
if (sData !== '')
oParams['data'] = sData;
oParams['method'] = sMethod;
oParams['url'] = sUrl;


var promise = new Promise(function (resolve, reject) {
$.ajax(oParams
).success(function (oResponse) {
$.ajax({
method: 'POST',
contentType: "text/plain",
data: JSON.stringify({
"headers": oHeaders,
"data": sData,
"method": sMethod,
"target": sUrl
}),
url: urlProxy
}).success(function (oResponse) {
resolve(oResponse);
})
.error(function(error) {
reject(error);
alert('Please try relogin');
});
});
var result = await promise;
Expand Down

0 comments on commit 93f92d6

Please sign in to comment.