Merged
Conversation
YvetteNikolov
commented
Mar 23, 2026
| * Restrict blocks for specific post types. | ||
| */ | ||
| #[Filter('allowed_block_types_all')] | ||
| public function restrictBlocksForPostTypes(bool|array $allowedBlockTypes, \WP_Block_Editor_Context $editorContext): bool|array |
Contributor
Author
There was a problem hiding this comment.
Todo: dit in Brave Hooks zetten
Contributor
There was a problem hiding this comment.
Pull request overview
Initial setup for Gutenberg block restrictions in the Sage theme, introducing configurable per-post-type allowed blocks and per-parent-block inner block restrictions, plus editor-side wiring.
Changes:
- Add PHP-based block whitelisting per post type via
allowed_block_types_allusing newconfig/gutenberg.phprestriction sets. - Add editor-side inner block restriction logic driven by
gutenberg.phpconfig exposed to the editor viawindow.theme. - Refactor block variations to register conditionally per post type; add editor CSS to hide the “all blocks” inserter panel.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| web/app/themes/sage/resources/styles/base/base-editor.css | Hides the “all blocks” inserter section in the editor UI. |
| web/app/themes/sage/resources/scripts/editor/editor.js | Loads the new block restrictions module in the editor bundle. |
| web/app/themes/sage/resources/scripts/editor/block-variations.jsx | Refactors variations into a registry and filters by current post type. |
| web/app/themes/sage/resources/scripts/editor/block-restrictions.js | Adds a blocks.registerBlockType filter to set allowedBlocks for inner blocks based on config. |
| web/app/themes/sage/config/gutenberg.php | Introduces blockSets, per-post-type restrictions, and per-parent-block inner restrictions. |
| web/app/themes/sage/app/Hooks/Theme.php | Implements post-type-level block restriction via allowed_block_types_all. |
| web/app/themes/sage/app/Hooks/Assets.php | Enqueues editor.css for the editor UI and exposes editor globals (currentPostType, gutenbergConfig) via window.theme. |
web/app/themes/sage/resources/scripts/editor/block-restrictions.js
Outdated
Show resolved
Hide resolved
web/app/themes/sage/resources/scripts/editor/block-restrictions.js
Outdated
Show resolved
Hide resolved
web/app/themes/sage/resources/scripts/editor/block-restrictions.js
Outdated
Show resolved
Hide resolved
YvetteNikolov
commented
Mar 24, 2026
rivanuff
reviewed
Mar 24, 2026
rivanuff
reviewed
Mar 24, 2026
laravdiemen
approved these changes
Mar 24, 2026
rivanuff
approved these changes
Mar 24, 2026
mvdhoek1
approved these changes
Mar 24, 2026
Yannicvanveen
approved these changes
Mar 24, 2026
mvdhoek1
requested changes
Mar 24, 2026
mvdhoek1
approved these changes
Mar 24, 2026
e8bdd90 to
f89bd7b
Compare
…ables reach the full editor
45537b0 to
74d6dbf
Compare
Composer package changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Je kunt nu via
config/gutenberg.phpblocks restricten op basis van:Ook kun je nu per block variation aangeven op welke post type deze wordt geregistreerd.