Skip to content
WP Engine Developers

Workflow

MediaPress Workflow allows you to save updates to published content without directly updating the original post until you are ready to do so.

This is achieved by creating a new draft ‘version’ of your published content, which can be worked on independently, and will override the original post when it is published.

This workflow can support various use cases. You can create an unlimited number of draft ‘versions’, work on them in isolation, decide whether or not to eventually publish them, and/or schedule them to be published in order.

This feature currently supports copy and merge of the following data:

  • Post title
  • Post excerpt
  • Post content
  • Post meta

By default, meta with the revisions_enabled argument set to true during registration will be transferred over to the draft copy (see here for more info). This is to avoid cloning inappropriate data, as revisioned meta is most likely to be related to content.

The filter wp_revisions_meta_keys can be used to adjust which meta is “revisions enabled”.

Our filter mediapress_workflow_meta_keys can be used to further customise the values that will be transferred to a draft copy, but this filter won’t be taken into account when publishing a draft copy and overwriting the original post.

See the root README.md for configuration steps for the base MediaPress plugin.

Workflow must be activated via the “MediaPress” settings page. No further configuration is necessary.

  • /docs - Contains the documentation for this module.
  • /inc - PHP source code
  • /src - JavaScript source code
  • /tests - Test coverage

Defines the post types on which the workflow functionality will be enabled.

Default Value

[ 'post', 'page' ]

Parameters

NameTypeDescription
post_typesarrayArray of post type slugs

Usage

add_filter( 'mediapress_workflow_supported_post_types', 'my_plugin_add_workflow_support' );
function my_plugin_add_workflow_support( array $post_types ): array {
$post_types[] = 'my_custom_post_type';
return $post_types;
}

Allows the adjustment of the post meta that will be cloned when a draft copy is created, and restored when a draft copy is published - overwriting the parent post values.

Parameters

NameTypeDescription
meta_keysarray<int, string>Array of meta keys
postWP_PostThe current post object

Usage

add_filter( 'mediapress_workflow_meta_keys', 'my_plugin_workflow_meta_keys' );
function my_plugin_workflow_meta_keys( array $meta_keys ): array {
if ( ! isset( $meta_keys['my_meta_key'] ) ) {
$meta_keys[] = 'my_meta_key';
}
return $meta_keys;
}

Allows the adjustment of the taxonomies that will be cloned when a draft copy is created, and restored when a draft copy is published - overwriting the parent post values.

This filter requires both the REST key and the actual taxonomy slug, since these may differ. e.g: [ 'tags' => 'post_tag' ].

Parameters

NameTypeDescription
taxonomiesarray<string, string>Array of taxonomy slugs and REST API keys [ ‘rest_key’ => ‘slug’ ]
postWP_PostThe current post object

Usage

add_filter( 'mediapress_workflow_taxonomies', 'my_plugin_workflow_taxonomies' );
function my_plugin_workflow_taxonomies( array $taxonomies ): array {
if ( ! isset( $taxonomies['my_taxonomy'] ) ) {
$taxonomies['my_taxonomy'] = 'my_taxonomy';
}
return $taxonomies;
}

Whether draft copies should be completely hidden from the post list screen.

Default: false

Parameters

NameTypeDescription
should_hidebooleanWhether to hide draft copies from the post list view

Usage

add_filter( 'mediapress_workflow_hide_draft_copies', '__return_true' );

When creating a draft ‘version’ of a post, a new post will be created with the meta key _mediapress_is_draft_copy set to true.

For performance reasons, we query posts based on the presence of this meta key, so it should only be present on posts when it has been specifically set by this plugin.

Posts with this meta key are excluded from queries by default so that they remain hidden from view unless specifically requested.

Draft ‘versions’ of a post have their parent set to the original post ID which is what allows us to relate them to one another.

Last updated: