Permalink
Browse files

abstract edit-flow support w/ single filter, fixes #14

  • Loading branch information...
1 parent d38392a commit 6947310c06a8267573835c6b4bc04e3ad1b29405 @benbalter committed Jun 15, 2012
Showing with 39 additions and 10 deletions.
  1. +14 −7 includes/admin.php
  2. +25 −3 wp-document-revisions.php
View
@@ -1195,24 +1195,31 @@ function delete_attachments_with_document( $postID ) {
wp_delete_attachment( $post->post_content, false );
}
-
-
+
/**
* Provides support for edit flow and disables the default workflow state taxonomy
* @since 1.1
* @return unknown
*/
function edit_flow_admin_support() {
-
- if ( !self::$parent->edit_flow_support() )
+ _deprecated_function( 'edit_flow_admin_support', '1.3.2 of WP Document Revisions', 'disable_workflow_states' );
+ }
+
+ /**
+ * Remove all hooks that activate workflow state support
+ * use filter `document_use_workflow_states` to disable
+ */
+ function disable_workflow_states() {
+
+ if ( self::$parent->use_workflow_states() )
return false;
-
+
remove_filter( 'manage_edit-document_columns', array( &$this, 'add_workflow_state_column' ) );
remove_action( 'manage_document_posts_custom_column', array( &$this, 'workflow_state_column_cb' ) );
remove_action( 'save_post', array( &$this, 'workflow_state_save' ) );
remove_action( 'admin_head', array( &$this, 'make_private' ) );
-
+
+
}
-
}
@@ -99,6 +99,7 @@ function __construct() {
//edit flow
add_action( 'init', array( &$this, 'edit_flow_support' ), 11 );
+ add_action( 'init', array( &$this, 'use_workflow_states' ), 50 );
//load front-end features (shortcode, widgets, etc.)
include dirname( __FILE__ ) . '/includes/front-end.php';
@@ -1435,13 +1436,34 @@ function edit_flow_support() {
if ( $edit_flow->custom_status->module->options->post_types['document'] == 'off' )
return false;
- //remove workflow state CT
- remove_action( 'admin_init', array( &$this, 'initialize_workflow_states' ) );
- remove_action( 'init', array( &$this, 'register_ct' ), 15 );
+ add_filters( 'document_use_workflow_states', '__return_false' );
return true;
}
+
+ /**
+ * Toggles workflow states on and off
+ * @return bool true if workflow states are on, otherwise false
+ */
+ function use_workflow_states() {
+
+ return apply_filters( 'document_use_workflow_states', true );
+
+ }
+
+ /**
+ * Removes front-end hooks to add workflow state support
+ */
+ function disable_workflow_states() {
+
+ if ( $this->use_workflow_states() )
+ return;
+
+ remove_action( 'admin_init', array( &$this, 'initialize_workflow_states' ) );
+ remove_action( 'init', array( &$this, 'register_ct' ), 15 );
+
+ }
/**

0 comments on commit 6947310

Please sign in to comment.