Action Directory / PublishToWordPress

Install

Prepares the parameters that will be used for WordPress Publishing workflow

Shared by Merter Sualp

Script

var parameters = prepareBlogPostParameters();
var workflowName = 'Publish';
app.openURL('workflow://run-workflow?name=' + encodeURIComponent(workflowName) + '&input=' + encodeURIComponent(parameters));

// you can add as many parameters as you like
function prepareBlogPostParameters() {
	var text = editor.getText();
	var endOfTitle = text.indexOf("\n");
	var title = text.substring(0, endOfTitle).trim();
	text = text.substring(endOfTitle+1).trim();
	var parametersAsJson = {
		"title" : title,
//		"newParameter" : value,
		"text"  : text
	};
	return JSON.stringify(parametersAsJson);
}