Skip to main content

Introduction to extensibility

The WordPress block editor is built with extensibility at its core. You can extend and customize nearly every aspect of the editor through well-defined APIs and hooks.
Extensibility in Gutenberg follows WordPress traditions while embracing modern JavaScript patterns, allowing developers to extend the editor without modifying core code.

Types of extensibility

The block editor provides several extensibility mechanisms:
  1. Block registration - Create custom blocks
  2. Block variations - Define variations of existing blocks
  3. Block transforms - Transform blocks between types
  4. Block filters - Modify block behavior and output
  5. Block styles - Add custom style variations
  6. Editor hooks - Extend editor functionality
  7. Slot/Fill system - Insert UI in predefined locations
  8. Data stores - Extend state management
  9. Format API - Add rich text formats
  10. Settings and preferences - Customize editor configuration

Creating custom blocks

The most common extensibility pattern is creating custom blocks.

Basic block registration

Use the @wordpress/create-block scaffolding tool to quickly generate block boilerplate:

Block variations

Block variations allow creating multiple configurations from a single block type:
Block variations provide different interfaces while sharing the same underlying block code, reducing duplication.

Block transforms

Enable blocks to transform between different types:

Block filters

Modify block behavior using WordPress hooks:

Adding custom attributes

Extending the edit component

Modifying block output

Common block filter hooks:
  • blocks.registerBlockType - Modify block settings during registration
  • editor.BlockEdit - Extend the block edit component
  • blocks.getSaveContent.extraProps - Add props to saved block wrapper
  • blocks.getBlockDefaultClassName - Customize default block class names

Block styles

Register alternative style variations for blocks:
With corresponding CSS:

Unregistering block styles

Hooks API

The WordPress hooks system (@wordpress/hooks) enables event-driven extensibility:

Adding filters

Adding actions

The hooks system mirrors PHP WordPress hooks but operates entirely in JavaScript, providing a familiar API for WordPress developers.

Slot/Fill system

Insert custom UI into predefined editor locations:

Using fills

Common plugin areas

  • PluginDocumentSettingPanel - Document settings sidebar
  • PluginSidebar - Custom sidebar
  • PluginSidebarMoreMenuItem - Sidebar menu item
  • PluginBlockSettingsMenuItem - Block settings menu
  • PluginPrePublishPanel - Pre-publish checklist
  • PluginPostPublishPanel - Post-publish panel
  • PluginPostStatusInfo - Post status panel

Creating custom slots

Extending data stores

Create custom data stores or extend existing ones:

Creating a custom store

Using the custom store

Format API

Add custom rich text formats:

Block bindings

Connect block attributes to external data sources:

Block patterns

Register custom block patterns:

Pattern categories

Block templates

Define starting content for blocks or post types:

Block templates for InnerBlocks

Post type templates

Template lock options:
  • 'all' - Prevents all changes
  • 'insert' - Prevents adding/removing blocks, allows reordering
  • false - No restrictions (default)

Editor settings customization

Modify editor settings and preferences:

Block supports API

Enable built-in block features:
The Block Supports API automatically adds UI controls and CSS generation for common styling features.

Server-side rendering

Register dynamic blocks with PHP rendering:

Best practices

  1. Use namespaces - Prefix all custom blocks, hooks, and stores with your plugin slug
  2. Follow WordPress coding standards - Use WordPress coding conventions
  3. Test compatibility - Verify your extensions work with WordPress versions
  4. Document your code - Provide JSDoc comments for public APIs
  5. Handle errors gracefully - Add error boundaries and fallbacks
  6. Use hooks correctly - Understand filter vs. action semantics
  7. Optimize performance - Memoize expensive computations
  8. Follow accessibility guidelines - Ensure keyboard and screen reader support
  9. Version your APIs - Plan for backward compatibility
  10. Stay updated - Follow Gutenberg release notes for API changes

Common extensibility patterns

Extending core blocks

A complete example of extending the paragraph block:

Resources and next steps