Skip to content

Commit

Permalink
abstract edit-flow support w/ single filter, fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter committed Jun 15, 2012
1 parent d38392a commit 6947310
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
21 changes: 14 additions & 7 deletions includes/admin.php
Expand Up @@ -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' ) );



}


}
28 changes: 25 additions & 3 deletions wp-document-revisions.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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 );

}


/**
Expand Down

0 comments on commit 6947310

Please sign in to comment.