A WordPress plugin that adds a custom Gutenberg block to display a modal dialog in the editor and on the frontend. The modal opens when a trigger (e.g. a button) is activated.
Blockparty Modal is a WordPress plugin that lets you add accessible modal dialogs to your content via the Gutenberg block editor. You define the modal content and behaviour in the editor; on the frontend, the modal is shown when the user activates a linked trigger (such as a button block).
- Native Gutenberg Block: Full integration with the WordPress block editor
- Modal dialog: Uses the native
<dialog>element for semantics and accessibility - Configurable content: Title (with heading level), rich text content, and optional close button
- Close behaviour: Choose how the modal closes β click outside, close button only, or prevent closing by backdrop
- Trigger linking: Link a block to open a specific modal via
linkedModalId; by default only the Button block is allowed as a trigger (filterable) - Stable modal ID: Each modal can have a unique ID for trigger association
- Layout & styling: Supports wide and full-width alignment, dimensions, colors, and spacing
- Internationalized: Multilingual support with translation files (French included)
- View script: Frontend script handles opening/closing and focus management
- WordPress: Version 6.8 or higher
- PHP: Version 8.1 or higher
- PHP Extension: ext-json
composer require beapi/blockparty-modal- Download the latest version of the plugin
- Extract the archive to the
/wp-content/plugins/folder - Activate the plugin from the WordPress "Plugins" menu
# Clone the repository
git clone https://github.com/BeAPI/blockparty-modal.git
cd blockparty-modal
# Install PHP dependencies
composer install
# Install JavaScript dependencies
npm install
# Build the assets
npm run build- Open the Gutenberg block editor
- Add a Modal block (e.g. search for "Modal" in the Widgets category)
- Configure the modal:
- Title and Heading level for the dialog heading
- Content (rich text) for the body
- Modal ID β set a unique ID so another block can open this modal (optional)
- Close behaviour β "Any" (click outside or close button), "Close button only", or "None"
- Close button β show or hide the close button
- Prevent scroll β lock body scroll when the modal is open
- To open the modal from a trigger block:
- Add a Button block (by default, only the Button block can be a modal trigger)
- In the block sidebar, open Attached modal and select the modal to open
- On the frontend, clicking that button will open the corresponding modal
By default, only the core/button block can be linked to a modal. To allow other blocks (e.g. paragraph, image, or custom blocks), use the filter blockparty_modal_trigger_allowed_blocks in your theme or plugin:
add_filter( 'blockparty_modal_trigger_allowed_blocks', function ( $blocks ) {
$blocks[] = 'core/paragraph';
$blocks[] = 'my-plugin/cta';
return $blocks;
} );- Filter name:
blockparty_modal_trigger_allowed_blocks - Parameters:
arrayβ List of block names (e.g.'core/button'). - Default:
array( 'core/button' )
The modal block uses InnerBlocks for its content. By default, a fixed set of blocks is allowed (paragraph, heading, list, image, button, etc.). To change which blocks can be inserted inside the modal, use the filter blockparty_modal_inner_allowed_blocks in your theme or plugin:
add_filter( 'blockparty_modal_inner_allowed_blocks', function ( array $blocks ) {
// Add more blocks
$blocks[] = 'core/cover';
$blocks[] = 'core/group';
return $blocks;
} );
// Or restrict to a subset
add_filter( 'blockparty_modal_inner_allowed_blocks', function () {
return [ 'core/paragraph', 'core/image', 'core/button' ];
} );- Filter name:
blockparty_modal_inner_allowed_blocks - Parameters:
arrayβ List of block names (e.g.'core/paragraph','core/button'). Default list includes paragraph, heading, list, image, gallery, video, buttons, embed, shortcode, etc.
blockparty-modal/
βββ src/ # Block sources
β βββ blockparty-modal/
β βββ block.json # Block configuration
β βββ edit.js # Edit component
β βββ save.js # Save component
β βββ view.js # Frontend open/close logic
β βββ index.js # Entry point
β βββ utils.js # Helpers (e.g. stable modal ID)
β βββ editor.scss # Editor styles
β βββ style.scss # Frontend styles
βββ build/ # Compiled assets (blocks-manifest.php, etc.)
βββ languages/ # Translation files
βββ blockparty-modal.php # Main plugin file
βββ composer.json # PHP dependencies
βββ package.json # JavaScript dependencies
# Development with hot reload
npm start
# Production build
npm run build
# JavaScript linter
npm run lint:js
# CSS linter
npm run lint:css
# Code formatting
npm run format
# Create plugin ZIP archive
npm run plugin-zip
# Start local development environment
npm run start:env
# Stop local development environment
npm run stop:env# Check code with PHP_CodeSniffer
composer cs
# Automatically fix code
composer cb
# Analyze with Psalm
composer psalm
# Run unit tests
composer phpunitThe project follows WordPress coding standards:
- WPCS (WordPress Coding Standards) for PHP
- ESLint with WordPress rules for JavaScript
- Psalm for PHP static analysis
- GrumPHP to automate pre-commit checks
The plugin uses @wordpress/env to create a local WordPress development environment:
# Start the environment
npm run start:env
# Access WordPress
# URL: http://localhost:8888
# Default credentials: admin / password
# Stop the environment
npm run stop:envThe project integrates several quality tools:
- PHP_CodeSniffer: PHP coding standards verification
- Psalm: PHP static code analysis
- PHPCompatibility: PHP compatibility verification
- PHP Parallel Lint: PHP syntax error detection
- GrumPHP: Pre-commit checks automation
The plugin is fully internationalized (text domain: blockparty-modal). Translation files are available in the languages/ folder.
- English (default)
- French
- Use the
languages/blockparty-modal.potfile as a base - Create your
.poand.mofiles - Place them in the
languages/folder
Contributions are welcome! To contribute:
- Fork the project
- Create a branch for your feature (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Make sure your code:
- Follows WordPress coding standards
- Passes all quality tests (PHPCS, Psalm, ESLint)
- Is properly documented
- Includes translations if necessary
This plugin is distributed under the GPL-2.0-or-later license. See the LICENSE file for more details.
Be API Technical Team
- Email: technical@beapi.fr
- Website: https://beapi.fr
- WordPress Block Editor Documentation
- WordPress Coding Standards
- Block API Reference
- HTML dialog element (MDN)
See readme.txt for the full version history. Recent highlights:
-
1.0.6
- Fix
blueprint.jsonconfig.
- Fix
-
1.0.5
- Add
blueprint.jsonto test the plugin on WordPress Playground. - Add
screen-reader-textclass to close button element when display icon only is selected.
- Add
-
1.0.4
- Filter
blockparty_modal_inner_allowed_blocksto control allowed blocks in the modal.
- Filter
-
1.0.3
- Fix: prevent adding linkedModalId attribute to non allowed blocks.
- Set min required PHP version to 8.1
-
1.0.2
- Filter
blockparty_modal_trigger_allowed_blocksto control which blocks can be modal triggers; dialog margin and InnerBlocks fixes. - Crawl Modal blocks from patterns
- Style issues
- Filter
-
1.0.1
- Filter
blockparty_modal_trigger_allowed_blocksto control which blocks can be modal triggers; dialog margin and InnerBlocks fixes.
- Filter
-
1.0.0
- Initial release (Modal block, trigger linking, close behaviour, i18n).
Developed with β€οΈ by Be API