Skip to content

Check: Editor blocks must use apiVersion 3 or higher (WordPress 7.0) #1205

@davidperezgar

Description

@davidperezgar

Add a static check that flags editor blocks whose block.json does not declare apiVersion 3 or higher, to align with the WordPress 7.0 iframe editor requirement.

Background
Starting with WordPress 7.0, the post editor will run in an iframe. Blocks are expected to use apiVersion 3 (or higher) for compatibility. Blocks with no apiVersion or with apiVersion < 3 may not behave correctly in the iframed editor.

References

Severity

  • New plugins (first-time submission): ErrorapiVersion 3+ must be present and correct; otherwise the check fails (mandatory).
  • Existing plugins (updates / “actual plugin” mode): Warning — same condition is reported as a warning so authors can fix it before it becomes mandatory.

Proposed behavior

  • Scope: All block.json files in the plugin (any directory).
  • Pass: Every block.json has apiVersion set to 3 or higher (e.g. 3, 4).
  • Fail:
    • apiVersion missing or empty, or
    • apiVersion set to 1 or 2 (or any number < 3).
  • Message: State that editor blocks must use apiVersion 3 or higher for WordPress 7.0+ and link to the migration/API version docs above.

Example failure (anonymized)

  • File: example-plugin/build/block.json (or some-plugin/includes/blocks/my-block/block.json).
  • Issue: apiVersion is not defined or empty.
  • Recommendation: Add "apiVersion": 3 (or higher) to block.json.

Implementation notes

  • Implement as a static check extending Abstract_File_Check: discover all block.json files under the plugin, parse JSON, validate apiVersion (presence and ≥ 3), and add one result per file (error or warning based on context).
  • Register the new check in Default_Check_Repository (or current equivalent).
  • Category: General or Plugin_Repo (e.g. Plugin_Repo if this is a directory requirement).
  • Severity by context:
    • New plugin submission: report as Error (mandatory).
    • Existing plugin (update / current plugin mode): report as Warning.
  • Add unit tests for: missing/empty apiVersion, apiVersion 1 or 2 (fail), and apiVersion 3+ (pass).

Acceptance criteria

  • All block.json files in the plugin are inspected.
  • Missing or empty apiVersion is reported (error for new plugins, warning for existing).
  • apiVersion 1 or 2 is reported as outdated (error for new, warning for existing); 3+ is accepted.
  • New plugins: check is mandatory (Error); existing plugins: Warning.
  • Check is registered and runs in the Plugin Check UI and WP-CLI.
  • Documentation updated if new checks are documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChecksAudit/test of the particular part of the plugin[Team] PluginsIssues owned by Plugins Team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions