New Beta version of Docs to WordPress

I’m working on a new version of the Docs to WordPress plugin and would love it if a few people could field test it to make sure I didn’t screw anything up. There were mostly a few simple fixes, though I added a new extender that allows you to use a delimiter (by default a |) in your doc to set the headline. The plugin also uses the WordPress HTTP API instead of CURL. Please check it out at http://plugins.svn.wordpress.org/docs-to-wordpress/trunk/

Still to come before the next full version: Image support and (hopefully) a better way to authenticate into Google.

Posted in Plugins | Leave a comment

Updates to the Docs to WordPress plugin forthcoming. What would you like to see?

I will be working shortly on some upgrades to the Docs to WordPress plugin and wanted to get some input on what people would like to see in the next version. There have been a lot of great ideas floated in the comments section on previous posts but I’d like to get them all in one place, if possible. Please leave your thoughts below.

Posted in Plugins | 5 Comments

Knight News Challenge

Just a quick shoutout: The BDN is very honored that our submission to the Knight News Challenge made it to Round 2. Our proposal is to take what we’ve done at the BDN, rewrite the code now that we have a better idea of what we’re doing and package it for release so that other news orgs can really easily implement what we’ve done here. If you have a second please visit the KNC website and leave your comments on the project.

Posted in Uncategorized | 2 Comments

Getting from WordPress to InDesign, part 1

This, I know, is the code a lot of people have been waiting for. It hasn’t been posted till now mostly because I’ve been trying to package everything to make it plug-and-play. At a certain point it was time to give up.

The code isn’t hard to grasp, but it will take some modification to get it to work.

Continue reading

Posted in Uncategorized | 10 Comments

Setting the head of a post using a delimiter in your doc

I’ve gotten a lot of requests from people using our Docs to WordPress plugin on how to set a headline that’s different from the title of your Doc, such as we do at the BDN using a pipe.

This isn’t a standard feature of the plugin, but the plugin does include a few filters to modify how posts are formatted. One of these filters is pre_docs_to_wp_insert, and it can be leveraged as such:

<?php
/*
Plugin Name: Extend Docs to WP like so
*/

add_filter( 'pre_docs_to_wp_insert', 'bdn_split_post' );
function bdn_split_post( $post_array = array() ) {

	$exploded_fields = explode( '|', $post_array[ 'post_content' ] );
	
	//Sometimes people forget a pipe, and we don't want to put the entire post in the headline
	if( is_array( $exploded_fields ) && count( $exploded_fields ) >= 2 ) {

		//Save the old title in case you want to do something with it
		$old_title = $post_array[ 'post_title' ];

		//Set the title to the first occurance.
		$post_array[ 'post_title' ] = strip_tags( $exploded_fields[ 0 ] );
		
		//Unset the title
		unset( $exploded_fields[ 0 ] );
		
		//Now restore the post content and save it
		$post_array[ 'post_content' ] = implode( '|', $exploded_fields );
		
	}

	return $post_array;

}

I haven’t tested it but the above code should do the trick.

Coming soon: Details on moving stories from WordPress to InDesign!

Posted in Plugins | 11 Comments

Update to Google Docs to WordPress plugin

A few weeks ago, unbeknownst to me, Google made a (wise) change to its APIs to require SSL for all API calls. This caused parts (but not all, apparently) of the Docs to WordPress plugin to stop working.

This evening I released an update to that plugin that should resolve any problems people had. In addition, I made a small change to make bold and italics come through more consistently.

As always, you can download the latest version in the WordPress Plugin Repository.

Posted in Plugins | 15 Comments

Media management in WordPress

Media management is, unfortunately, one of the weaker points of WordPress. There are some exciting changes coming for 3.3, but they don’t address some of the core deficiencies, such as the inability to attach a photo to multiple posts.

Continue reading

Posted in Plugins | 8 Comments

On killing our MySQL servers with WP-Cron (updated)

We had a fun time killing our site in an unusual manner last night and again this morning.

Continue reading

Posted in Performance | 1 Comment

Updated Docs to WordPress plugin: Now with better formatting

Version 0.3-beta of our Docs to WordPress plugin has been released. It’s a fairly minor release, and only affects people using the cleaner extension, but we just rolled it out internally this morning at the BDN and it’s exciting for us, so I wanted to pass it on to the public.

The newest version of the cleaner extension passes correctly parses bold and italic text and headings, such as <h4>. It also strips out span tags to avoid a few instances where they would cause an extra line break.

In an earlier version of Docs, bold and italic text were surrounded by <em> and <strong> tags, as would be expected. It made it very easy to handle stylized text.

In the newest version of Docs, however, text formatting is done completely via CSS. So the header of each of the HTML versions of the Doc contains a stylesheet, where bold and italic text is given an arbitrary class name.

To carry that through to WordPress, I use preg_match to find the correct class name from the stylesheet and then preg_replace to convert span tags to <em> and <strong>. Thanks much to Andrew Nacin, Rob Flaherty Bill, who replied to my cry for help.

As always, the Docs to WordPress plugin can be found in the WordPress Plugin Repository.

Posted in Plugins | 18 Comments

Appeal for help, because I’m terrible at regex

One of the most annoying things about using Google Docs is that none of the styles are inline. It used to be that bold text was wrapped in a <strong> tag and italic text was wrapped in am <em> tag. No longer. Now each style of text is wrapped in a span with a number of different classes applied to it. Those styles don’t carry through when we bring the text into WordPress and the names of the classes vary from article to article. This can be very annoying for columnists who bold names of subjects, for example.

So, what I’m looking for is a regex expression to turn <span class=”c0 c3″>My text</span> into <span class=”c0 c3″><strong>My text</strong></span> where class c3 is the bold class, for example.

Posted in Uncategorized | 11 Comments