⚠️ Experimental Feature: Block editor support and the REST API for documents are both experimental and opt-in. The classic editor remains the default, recommended, and most thoroughly tested interface. Enable the block editor only if you want to evaluate the new experience and are comfortable with potential rough edges. Please report any issues you encounter.
WP Document Revisions includes experimental support for the WordPress block editor (Gutenberg). By default, documents use the classic editor, which provides a streamlined, purpose-built upload interface. The block editor can be enabled for evaluation when you want to try the newer WordPress editing experience for documents.
Add the following two filters to your theme’s functions.php or a custom plugin:
// Enable REST API for documents (required for block editor).
add_filter( 'document_show_in_rest', '__return_true' );
// Enable the experimental block editor for documents.
add_filter( 'document_use_block_editor', '__return_true' );
Alternatively, create a must-use plugin at wp-content/mu-plugins/enable-block-editor.php:
<?php
// Experimental: Enable block editor for documents.
add_filter( 'document_show_in_rest', '__return_true' );
add_filter( 'document_use_block_editor', '__return_true' );
To disable the block editor, simply remove these filters.
Both filters are required. document_show_in_rest exposes documents to the WordPress REST API (also experimental), and document_use_block_editor configures the plugin for block editor compatibility (enables Gutenberg for documents, allows REST write methods, adds excerpt support, and registers post meta). Enabling document_show_in_rest alone provides read-only REST API access without the block editor.
When the block editor is enabled, a Document panel appears in the Settings sidebar with the following features:
post_content on saveA textarea field for describing what changed in this version. This maps to the post excerpt and appears in the document’s revision history, just like the classic editor’s “Revision Summary” metabox.
When another user is editing the document, a warning banner shows their name and the upload button is disabled. This uses the WordPress core editor lock (not the plugin’s custom document lock with document_lock_check filter).
New documents cannot be published until a file is attached. The editor’s Publish/Update button is locked until you select a file.
| Feature | Classic Editor | Block Editor |
|---|---|---|
| Upload method | ThickBox iframe with plupload | WordPress media library modal |
| File storage | Direct post_content write |
REST API meta sync |
| Feedback | Inline HTML notices | WordPress Snackbar notices |
| Lock system | Plugin’s document_lock_check filter |
Core editor lock |
| Revision summary | Custom metabox | Sidebar textarea (post excerpt) |
| Workflow states | Taxonomy metabox | Taxonomy panel in sidebar |
When block editor support is enabled, documents are exposed via the WordPress REST API at /wp-json/wp/v2/{document_slug}/. The plugin registers a document_attachment_id post meta field for REST read/write, and automatically syncs it to post_content (where the attachment reference is stored as <!-- WPDR {ID} -->).
POST, PUT, and DELETE methods are allowed when the block editor is enabled. All write methods require a valid nonce.
WP Document Revisions also provides three Gutenberg blocks for displaying documents on the front end, available regardless of whether the document post type uses the block editor:
wp-document-revisions/documents-shortcode) — Displays a list of documents, equivalent to the [documents] shortcodewp-document-revisions/documents-widget) — Shows recently updated documents, equivalent to the sidebar widgetwp-document-revisions/revisions-shortcode) — Shows the revision history for a specific document, equivalent to the [document_revisions] shortcodedocument_lock_check filter used in the classic editor