Skip to content

feat/block restrictions#79

Merged
YvetteNikolov merged 14 commits intomainfrom
feat/block-restrictions
Mar 30, 2026
Merged

feat/block restrictions#79
YvetteNikolov merged 14 commits intomainfrom
feat/block-restrictions

Conversation

@YvetteNikolov
Copy link
Copy Markdown
Contributor

@YvetteNikolov YvetteNikolov commented Mar 23, 2026

Je kunt nu via config/gutenberg.php blocks restricten op basis van:

  • Post Type
  • Parent block

Ook kun je nu per block variation aangeven op welke post type deze wordt geregistreerd.

* Restrict blocks for specific post types.
*/
#[Filter('allowed_block_types_all')]
public function restrictBlocksForPostTypes(bool|array $allowedBlockTypes, \WP_Block_Editor_Context $editorContext): bool|array
Copy link
Copy Markdown
Contributor Author

@YvetteNikolov YvetteNikolov Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: dit in Brave Hooks zetten

@YvetteNikolov YvetteNikolov marked this pull request as ready for review March 24, 2026 07:50
@YvetteNikolov YvetteNikolov requested a review from a team as a code owner March 24, 2026 07:50
Copilot AI review requested due to automatic review settings March 24, 2026 07:50
@YvetteNikolov YvetteNikolov requested a review from a team as a code owner March 24, 2026 07:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_all using new config/gutenberg.php restriction sets.
  • Add editor-side inner block restriction logic driven by gutenberg.php config exposed to the editor via window.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.

@YvetteNikolov YvetteNikolov force-pushed the feat/block-restrictions branch from 45537b0 to 74d6dbf Compare March 30, 2026 08:20
@github-actions
Copy link
Copy Markdown

Composer package changes
Prod Packages Operation Base Target Link License
gravitykit/gravity-forms-zero-spam Upgraded v1.7.2 v1.7.3 Compare GPL-2.0-or-later
league/flysystem Upgraded 3.32.0 3.33.0 Compare MIT
plugin/yard-gutenberg Upgraded v1.5.2 v1.5.5 Compare EUPL-1.2
sentry/sentry Upgraded 4.23.0 4.23.1 Compare MIT
spatie/flare-client-php Upgraded 1.10.1 1.11.0 Compare MIT
spatie/ignition Upgraded 1.15.1 1.16.0 Compare MIT
wp-cli/php-cli-tools Upgraded v0.12.8 v0.12.9 Compare MIT
wp-cli/wp-config-transformer Upgraded v1.4.4 v1.4.5 Compare MIT
yard/brave-csp Upgraded v1.4.1 v1.4.2 Compare EUPL-1.2
yard/brave-hooks Upgraded v2.3.1 v2.4.0 Compare MIT
yard/wp-user-roles Upgraded v2.0.3 v2.0.4 Compare MIT
Dev Packages Operation Base Target Link License
captainhook/captainhook Upgraded 5.29.0 5.29.2 Compare MIT
yard/lando-brave Upgraded v1.3.6 v1.3.7 Compare EUPL-1.2

@YvetteNikolov YvetteNikolov merged commit bc07cb6 into main Mar 30, 2026
3 checks passed
@YvetteNikolov YvetteNikolov deleted the feat/block-restrictions branch March 30, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants