P2 Resolved Posts: Only mark a specific category as unresolved

In the WordPress.org forums, ameeromar asks:

Hey would it be possible to limit the automatically marking as unresolved to one category? This would be particularly useful for my category ‘tasks’ which need to be marked as unresolved when published (and then marked as resolved when completed).

It’s totally possible using a combination of a couple filters. Here’s what the annotated code snippet looks like:

/**
 * P2 Resolved Posts: Only mark 'task' posts as unresolved
 *
 * @see http://danielbachhuber.com/2013/04/18/p2-resolved-posts-only-mark-a-specific-category-as-unresolved/
 */
// Marks all new posts as unresolved
add_filter( 'p2_resolved_posts_mark_new_as_unresolved', '__return_true' );
// Let us apply conditional logic to when posts are marked unresolved
add_filter( 'p2_resolved_posts_maybe_mark_new_as_unresolved', 'p2rpx_only_mark_tasks', 10, 2 );
function p2rpx_only_mark_tasks( $ret, $post ) {

	// Get all of the categories assigned to the post
	$cats = get_the_terms( $post->ID, 'category' );
	// Make sure this didn't return false or a WP_Error object
	if ( is_array( $cats ) ) {

		// Use wp_filter_object_list() to see if there are any 'task' terms
		$task = wp_filter_object_list( $cats, array( 'slug' => 'task' ) );
		// If there is a task term, we want to mark unresolved. Otherwise, no.
		if ( ! empty( $task ) )
			$ret = true;
		else
			$ret = false;
	}

	return $ret;
}

However, in a stock P2 install, there isn’t a frontend interface for setting the category. The category is determined by the post format you use. Other users might be better off searching for tags by switching the term lookup to: get_the_terms( $post->ID, 'post_tag' );

Farewell, Automattic

To be is to do
What you do must be filling
Search for gas stations

Earlier this week I made the difficult decision to leave Automattic, where I’ve been working on the VIP team for just shy of two years. It’s been a tremendous ride — I’m truly proud of who I’ve been able to work with, and what we’ve been able to get done.

I’ve felt my personal growth slow in recent months, however. Considering where I’m at in my career, and that Leah is busy with school, I’m looking for a more challenging opportunity — one that pushes me to learn, grow, and lead. If you have or know of such an opportunity, I’d love to hear from you: d@danielbachhuber.com

Here’s my updated resume.

NewsBlur

After a long run with Google Reader, I’m switching over to NewsBlur. Two key points to the decision: it’s open source and Samuel is experimenting with ways to enhance your information management.

For the former, one idea that’s already come up: I’d love to contribute “Share to WordPress” integration. Oh, and it would be really neat to pull comments already on the post into the reading experience. There seem to be some type of comments limited to just NewsBlur.

The user experience has significant room for improvement. Hopefully he takes the dough he’s pulling in now to hire a proper designer.

It’s also been on my list for a long time to cull my feed subscriptions. Based on what I’m seeing, roughly 90% of blogs died between 2010 and early 2012.

On that note, you need to watch Anil Dash’s “The Web We Lost”:

“The first thing you do, when you succeed in Silicon Valley and your company is acquired, is destroy everyone’s wedding photos [...] The reality is those of us that [cared about open formats] have lost.”

It’s time the Open Web became the cool thing to hack on again.

Code With Me comes to Portland!

Code With Me, an affordable, two-day introduction to HTML / CSS / jQuery for tech-savvy journalists, is coming to Portland! Even better: a two to one student to mentor ratio means you’ll never get stuck or lost.

Applications to attend are due this coming Saturday, April 6th, at 9 pm Pacific. Apply now and please spread the word.

Many thanks to The Oregonian and the Knight-Mozilla OpenNews project for their support.