WP Document Revisions

Block Editor (Gutenberg) Support — Experimental

⚠️ 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.

How to Opt In

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.

Document Sidebar Panel

When the block editor is enabled, a Document panel appears in the Settings sidebar with the following features:

File Upload

File Information

Revision Summary

A 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.

Lock Status

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).

Save Protection

New documents cannot be published until a file is attached. The editor’s Publish/Update button is locked until you select a file.

Error Handling

How It Differs from the Classic Editor

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

Technical Details

REST API

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.

Blocks

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:

Known Limitations