Docs / Block Restore

Block Restore

Restore a single block from an old revision, not the whole post.

Hooks

Every default, limit and message has a filter, and every change fires an action.

axle_block_restore_post_typesFilter
( string[] $post_types )

Post types that get Axle Block Restore in the post editor and the abilities. Default every REST-enabled post type with revisions and the editor. Types without revisions are dropped

axle_block_restore_site_editor_post_typesFilter
( string[] $post_types )

Post types that get it in the Site Editor. Default wp_template, wp_template_part and wp_block. Types that do not exist, have no revisions or are not in the REST API are dropped

axle_block_restore_capabilityFilter
( string $capability, string $post_type )

Capability a user needs before the scripts load for a post type. Default the type’s own edit_posts capability: edit_theme_options for templates and parts, edit_posts for patterns and posts. An empty value falls back to the default

axle_block_restore_copy_post_typesFilter
( string[] $post_types )

Post types the Another post view copies from, and the search route allows. Default every post type the user can edit that has Axle Block Restore. Types the user cannot edit are dropped. An empty array turns the view off and makes the route answer 403

axle_block_restore_copy_max_resultsFilter
( int $max )

Most posts one search returns. Default 20

axleBlockRestore.canRestoreFilter
( boolean canRestore, Object block )

Whether a block’s menu and the "Restore selected block" command are offered for a block

axleBlockRestore.revisionsPerPageFilter
( number perPage )

Revisions loaded at a time, 1 to 100. Default 50

axleBlockRestore.removedRevisionsFilter
( number count )

How many of the newest revisions the Removed blocks view looks through, 1 to 100. Default 20

axleBlockRestore.removedSimilarityFilter
( number similarity )

Share of words, 0 to 1, a block of the same type now must have in common with an old block for it to count as edited, not removed. Default 0.6. 1 lists every block that is not identical

axleBlockRestore.removedBlocksFilter
( Object[] entries, { revisionIds } )

The blocks listed as removed, newest removal first. Each has name, title, text, path, block, revisionId, revisionIds and rewritten

axleBlockRestore.copyPostTypesFilter
( string[] postTypes )

Post types the Another post view offers. Can only narrow the PHP list. An empty array hides the view

axleBlockRestore.attributeRoleFilter
( string role, string name, string blockName, Object schema )

Whether an attribute is content, style or keep for a partial restore. Default from block.json role, the attribute’s source and the style list. Any other return value is ignored

axleBlockRestore.styleAttributesFilter
( string[] names, string blockName )

Attribute names that count as style. Default style, className, align, layout, backgroundColor, textColor, fontSize, fontFamily, gradient, borderColor

axleBlockRestore.restoreModesFilter
( string[] modes )

Ways to restore one block: replace, content, style. Default all three. replace is always kept, unknown names are dropped

axleBlockRestore.commandsFilter
( Object[] commands, string|null blockId )

Command palette entries, each { name, label, icon, callback }. Add, change or remove entries

axleBlockRestore.openedAction
( { clientId, postType, postId, focusSearch, view } )

The window opened. view is revisions or removed. clientId is null for the whole post, template, part or pattern. Template and part IDs look like theme//slug

axleBlockRestore.restoredAction
( { mode, block, revisionId, postId, postType } )

A block came back. mode is replace, content, style, insert-after, replace-at, insert-at, inner-replace, inner-insert, removed-place, removed-end, removed-below, other-post-below or other-post-end. For the last two the details also have sourcePostId and sourcePostType, and revisionId is a revision of that post or current

The full reference, with the PHP API and examples, is in REFERENCE.md for version 3.1.0