Skip to content

Public API for the fields and assets of a registered block #115

Closed

Description

@Contributolo

We use a small tool that checks block markup before it is saved (for AI-assisted content editing): it validates attrs.blockstudio.attributes against the fields of each Blockstudio block and previews a block together with the CSS and JS it adds. To do that it currently relies on internals that are not documented and could change in any release:

  • Field definitions: the blockstudio property Blockstudio sets on the registered WP_Block_Type ($type->blockstudio['attributes']), plus the blockstudio attribute to tell Blockstudio blocks apart.
  • Block assets: Blockstudio\Build::data() to find the assets of a block, Assets::get_id() for the handle, Assets::get_path() and Files::get_relative_url() for the URL. Block CSS and JS are added through the output buffer rather than wp_enqueue_*, so they cannot be read from wp_styles() / wp_scripts().

Would you consider a small public, documented API for this, next to the existing bs_* helpers? For example:

// Field definitions of a registered Blockstudio block, null for other blocks.
bs_block_fields( string $name ): ?array;

// The assets a block adds: type (style/script/module), handle, URL or inline, scope (editor/frontend).
bs_block_assets( string $name ): array;

Names and shape are only a suggestion. If you like the idea I can open a PR with the functions, docs and tests, or adapt it to whatever fits Blockstudio's design better.

Activity

  1. added a commit that references this issue on Oct 15, 2026
    6902dfd
  2. dnnsjsk commented on Oct 15, 2026

    @dnnsjsk
    Contributor

    Released in Blockstudio 7.7.2. The documented public helpers are bs_block_fields() and bs_block_assets(), implemented in 6902dfd6. The release also includes bs_block_extension_fields() from #121 for fields added by matching extensions, including on core and third-party blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions