Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Automatically mark new posts as unresolved by adding `add_filter( 'p2…

…_resolved_posts_mark_new_as_unresolved', '__return_true' );` to your theme's functions.php. Thanks macmeister for the request

Closes #6
  • Loading branch information...
commit 4402492cd5e61eb60b5a817259bc5ec8c015c17c 1 parent b9a1682
@danielbachhuber danielbachhuber authored
Showing with 21 additions and 0 deletions.
  1. +20 −0 p2-resolved-posts.php
  2. +1 −0  readme.txt
View
20 p2-resolved-posts.php
@@ -53,6 +53,11 @@ function after_setup_theme() {
$this->register_taxonomy();
if ( ! term_exists( 'unresolved', self::taxonomy ) )
wp_insert_term( 'unresolved', self::taxonomy );
+
+ // Posts can be marked unresolved automatically by default
+ // if the user wishes
+ if ( apply_filters( 'p2_resolved_posts_mark_new_as_unresolved', false ) )
+ add_action( 'publish_post', array( $this, 'mark_new_as_unresolved' ) );
}
/**
@@ -497,6 +502,21 @@ function single_audit_log_output( $args ) {
return $html;
}
+ /**
+ * Automatically mark a newly published post as unresolved
+ * To enable, include the following in your theme's functions.php:
+ * - add_filter( 'p2_resolved_posts_mark_new_as_unresolved', '__return_true' );
+ *
+ * @since 0.2
+ */
+ function mark_new_as_unresolved( $post_id ) {
+ wp_set_post_terms( $post_id, array( 'unresolved' ), self::taxonomy );
+ $args = array(
+ 'new_state' => 'unresolved',
+ );
+ $this->log_state_change( $post_id, $args );
+ }
+
}
$p2_resolved_posts = new P2_Resolved_Posts();
View
1  readme.txt
@@ -34,6 +34,7 @@ Feel free to ask a question in the forums!
== Changelog ==
= 0.2 (??? ?? ????) =
+* Automatically mark new posts as unresolved by adding `add_filter( 'p2_resolved_posts_mark_new_as_unresolved', '__return_true' );` to your theme's functions.php. Thanks [macmeister](http://wordpress.org/support/topic/plugin-p2-resolved-posts-default-to-unresolved) for the request
* Display an error notice if you've activated the plugin but P2 isn't the currently active theme
= 0.1 (Mar. 23, 2012) =
Please sign in to comment.
Something went wrong with that request. Please try again.