Flickr Blog This to a WordPress Draft Post

Filed Under Geek, Hacks and Mods, Wordpress on 2009-11-19, 00:10

This is a boring geeky entry, but if you’re looking for this info it might be helpful. I’ve started a new blog (yes, another one) called My Cat Is Broken. It’s a collection of pics and videos of cats being, well broken. Usually it’s our cats. Everyone knows that Flickr is a great place to find cat pics, and I’ve started keeping my eye out for pictures of cats being dumb. When I find one, a quick click of the Blog This button, some title and text and it’s instantly on my site.

But I don’t necessarily want these pics to be published instantly, I’d rather they be saved as drafts for manual publishing later. I found links to an old plugin that’s not even available in the WordPress plugin database called Flickr Blog This To Draft, but the site was down, the plugin unavailable, and I was impatient. I took matters into my own hands.

A quick hack of the xmlrpc.php (in the root directory of my WordPress install) and I was in business. The line to change (as of WordPress 2.8.6) is line 2097 which has the following code:

$post_status = $publish ? ‘publish’ : ‘draft’;

There are multiple ways to change this, but I just commented out that line and hardcoded $post_status to draft.

// $post_status = $publish ? ‘publish’ : ‘draft’;
$post_status = ‘draft’;

The thing to remember here though is that when you upgrade WordPress to the next version for yet another security issue, you’ll have to redo this modification. If you make a copy of your xmlrpc.php file then you can just run a command line diff against the upgraded version after every upgrade. If that’s the only line that changed, copy it back, otherwise jump in manually and re-find that line and fix it. Note though that this means all of your posts will be automatically set to draft. In my case that’s perfectly alright, but you may want to toss some code in there to determine this based on your title or something (i.e. titles that start with “DRAFT” go to drafts, but anything else gets published).


Comments