Skip to content

feat: add block auto register support#32

Open
Yannicvanveen wants to merge 1 commit into
mainfrom
feat/auto-register-support
Open

feat: add block auto register support#32
Yannicvanveen wants to merge 1 commit into
mainfrom
feat/auto-register-support

Conversation

@Yannicvanveen

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds opt-in “auto register” behavior to the block registrar so blocks can be registered directly from args (without requiring an explicit block_type reference), aligning with the referenced WordPress “PHP-only block registration” direction.

Changes:

  • Iterates configured blocks with their array keys as $blockName.
  • Adds an autoRegister flag check under supports to decide whether to register by name ({$namespace}/{$blockName}).
  • Introduces a small helper (shouldAutoRegister) to encapsulate the flag detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Registrar.php
Comment on lines +60 to +63
private function shouldAutoRegister(array $blockArgs): bool
{
return ! empty($blockArgs['supports']['autoRegister']);
}
Comment thread src/Registrar.php
Comment on lines +35 to +37
$namespace = wp_get_theme()->get('TextDomain') ?? 'theme';

\register_block_type("{$namespace}/{$blockName}", $blockArgs);
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.

2 participants