Workflow
MediaPress Workflow
Section titled “MediaPress Workflow”Table of Contents
Section titled “Table of Contents”DescriptionLocal Setup InstructionsAdditional ConfigurationFile StructureFilters/ActionsData Structure
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.
Local Setup Instructions
Section titled “Local Setup Instructions”See the root README.md for configuration steps for the base MediaPress plugin.
Additional Configuration
Section titled “Additional Configuration”Workflow must be activated via the “MediaPress” settings page. No further configuration is necessary.
File Structure
Section titled “File Structure”/docs- Contains the documentation for this module./inc- PHP source code/src- JavaScript source code/tests- Test coverage
PHP Reference
Section titled “PHP Reference”Filters
Section titled “Filters”mediapress_workflow_supported_post_types
Section titled “mediapress_workflow_supported_post_types”Defines the post types on which the workflow functionality will be enabled.
Default Value
[ 'post', 'page' ]
Parameters
| Name | Type | Description |
|---|---|---|
| post_types | array | Array 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;}mediapress_workflow_meta_keys
Section titled “mediapress_workflow_meta_keys”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
| Name | Type | Description |
|---|---|---|
| meta_keys | array<int, string> | Array of meta keys |
| post | WP_Post | The 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;}mediapress_workflow_taxonomies
Section titled “mediapress_workflow_taxonomies”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
| Name | Type | Description |
|---|---|---|
| taxonomies | array<string, string> | Array of taxonomy slugs and REST API keys [ ‘rest_key’ => ‘slug’ ] |
| post | WP_Post | The 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;}mediapress_workflow_hide_draft_copies
Section titled “mediapress_workflow_hide_draft_copies”Whether draft copies should be completely hidden from the post list screen.
Default: false
Parameters
| Name | Type | Description |
|---|---|---|
| should_hide | boolean | Whether to hide draft copies from the post list view |
Usage
add_filter( 'mediapress_workflow_hide_draft_copies', '__return_true' );Data structure
Section titled “Data structure”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.