Skip to content

Initial set of block-related commands #554

@swissspidy

Description

@swissspidy

From wp-cli/ideas#119

Some more concrete ideas:

  • wp post has-blocks <id> - Whether the post has any blocks. Uses the has_blocks() function.
  • wp post has-block <id> <block> - Whether the post contains any specific block type. Uses the has_block() function.
  • Add a new block_version field to wp post get that uses block_version()
  • wp block list - List all registered block types (WP_Block_Type_Registry)
  • wp block get <block> - Get information about a specific registered block type (WP_Block_Type)
  • wp block parse <id> - Run parse_blocks() on a specific post ID and return the raw JSON tree structure.
  • wp block render <id> - Run do_blocks() to render the specific blocks of a post and return the final HTML.
  • wp pattern list [--category=<cat>] - List all registered block patterns (WP_Block_Patterns_Registry).
  • wp pattern get <id> - Get a specific block pattern

Notes:

  • This functionality was added in WordPress 5.0+, but we still support WordPress 4.9. Thus, we need to make these commands available only conditionally, for example with a before_invoke hook and an appropriate error message.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions