Editorial Workflows

Post To WordPress

unlisted workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Publish a post to WordPress. Extract a URL at the top of the document to optionally assign it to a custom field. Launch another workflow at the end to shorten the just-published post with Bitly.

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
cats
Value
Set Variable ?
Variable Name
thetags
Value
Check Title ?
Title
Double Check Title
Initial Text
File Name%cursor
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
postname
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
doctext
Value
Input
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Set Variable ?
Variable Name
content
Value
Input
Normal or Linked? ?
Title
Post Type
Message
Linked or normal post?
Button 1
Linked
Output Value
linked
Button 2
Normal
Output Value
normal
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Extract Linked URL ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
linked
Generate Text ?
Text
doctext
Extract URLs ?
Output
  • Only URLs
  • URLs and Ranges (Separated by Tab)
Select from List ?
Title
Select Linked URL
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
ON
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
Set Variable ?
Variable Name
linkedurl
Value
Selected Text
Select Range ?
Range (from:to)
Sel. Range: Start:Sel. Range: End + 1
Relative to
  • Entire Document
  • Current Selection
Replace Selected Text ?
Replacement Text
Document Text ?
Folded Text
  • Include
  • Replace with:
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Set Variable ?
Variable Name
content
Value
Input
…End If
Get WordPress Categories ?
Source Code
import xmlrpclib
import workflow
import keychain
import console

categories = workflow.get_variable("cats")
 
wp_url = "Link to your xmlrpc.php file"
wp_username = 'username'
wp_password = keychain.get_password('website', 'username')
wp_blogid = ""

console.show_activity('Fetching categories...')
 
server = xmlrpclib.ServerProxy(wp_url)
 
cat = server.wp.getTerms(wp_blogid, wp_username, wp_password, 'category')

i = 0
for x in cat:
	categories += '\n' + x['name'] + "	" + str(i)
	i = i+1
	workflow.set_variable("cats", categories)
console.hide_activity()
Generate Text ?
Text
cats
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Choose Category ?
Title
WordPress Categories
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
ON
Set Variable ?
Variable Name
catID
Value
Input
Get WordPress Tags ?
Source Code
import xmlrpclib
import workflow
import keychain
import console

tags = workflow.get_variable("thetags")
 
wp_url = "Link to your xmlrpc.php file"
wp_username = 'username'
wp_password = keychain.get_password('website', 'username')
wp_blogid = ""

console.show_activity('Fetching tags...')
 
server = xmlrpclib.ServerProxy(wp_url)
 
tag = server.wp.getTerms(wp_blogid, wp_username, wp_password, 'post_tag')

i = 0
for x in tag:
	tags += '\n' + x['name'] + "	" + str(i)
	workflow.set_variable("thetags", tags)
	i = i+1
console.hide_activity()
Generate Text ?
Text
thetags
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Choose Tags ?
Title
WordPress Tags
List (Lines)
Input
Multiple Selection
ON
Show in Popover
ON
Set Variable ?
Variable Name
tagID
Value
Input
Publish To WordPress ?
Source Code
import xmlrpclib
import workflow
import clipboard
import console
import keychain
 
wp_url = "Link to your xmlrpc.php file"
wp_username = 'username'
wp_password = keychain.get_password('website', 'username')
wp_blogid = ""
 
status_draft = 0
status_published = 1

console.show_activity('Opening connection...')

server = xmlrpclib.ServerProxy(wp_url)
 
title = workflow.get_variable('postname')
content = workflow.get_variable('content')

cat = server.wp.getTerms(wp_blogid, wp_username, wp_password, 'category')
tag = server.wp.getTerms(wp_blogid, wp_username, wp_password, 'post_tag')

cat_nb = workflow.get_variable("catID")
tags_nb = workflow.get_variable("tagID")

tagnew = tags_nb.split('\n')
 
tags = []
for x in tagnew:
	tags.append(tag[int(x)]['name'])
 
categories = [cat[int(cat_nb)]['name']]

linkcheck = workflow.get_variable('linkedurl')

if linkcheck is not None:
	data = {'title': title, 'description': content, 'post_type': 'post', 'categories': categories, 'mt_keywords': tags, 'custom_fields': [{'value': linkcheck, 'key': 'externalLink'}]}
elif linkcheck is None:
	data = {'title': title, 'description': content, 'post_type': 'post', 'categories': categories, 'mt_keywords': tags}

console.show_activity('Publishing...')
 
post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, status_published)
 
post_infos = server.metaWeblog.getPost(post_id, wp_username, wp_password)

console.hide_activity()
 
# print post_infos['link']
# clipboard.set(post_infos['link'])

console.hud_alert('Post published', 'Success', 1.0)
workflow.set_output('Success')
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Success
Open URL ?
Open in
  • In-App Browser
  • Default App / Safari
URL
EDITORIAL COMMAND URL OF CHAINED WORKFLOW
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
…End If