WordPress.org

Make WordPress Core

Opened 11 days ago

Last modified 4 days ago

#48529 assigned enhancement

Add fields to WP_Block_Type

Reported by: spacedmonkey Owned by: spacedmonkey
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords: has-patch
Focuses: Cc:
PR Number:

Description

As part of #47620 and the RFC for block registeration. Server registered blocks are missing some fields. These fields include.

  • title
  • category
  • parent
  • icon
  • description
  • keywords
  • textDomain
  • styleVariations

Recommended addictional fields

  • supports
  • example

Attachments (2)

48529.diff (3.7 KB) - added by spacedmonkey 11 days ago.
48529-implement.diff (8.8 KB) - added by spacedmonkey 10 days ago.

Download all attachments as: .zip

Change History (9)

@spacedmonkey
11 days ago

#1 @spacedmonkey
10 days ago

This ticket is a blocker for #47620.

#2 @gziolo
10 days ago

This looks great, what's necessary to test it and land it? Does it require changes in unit tests?

#3 @spacedmonkey
10 days ago

Good question @gziolo . I will take a look. But the tests should be simple.

We also need to add the fields in for currently registered blocks. I made a start with 48529-implement.diff.

We will also need to update the social links in the plugin.

Last edited 10 days ago by spacedmonkey (previous) (diff)

#4 follow-up: @aduth
4 days ago

There's at least one condition which tests isset on a property of this class, where we're now always assigning a default. Do those need to be updated?

https://github.com/WordPress/wordpress-develop/blob/6cf77db/src/wp-includes/class-wp-block-type.php#L134-L138

#5 in reply to: ↑ 4 @spacedmonkey
4 days ago

Replying to aduth:

There's at least one condition which tests isset on a property of this class, where we're now always assigning a default. Do those need to be updated?

What if someone doesn't register attributes in their plugin for their custom block. That check might be overkill, but might stop a breakable if someone does something silly.

#6 @aduth
4 days ago

But unless I'm mistaken, since the patch proposes to assign a default value for $attributes, that condition could never be true (unless someone went out of their way to unset( $block_type->attributes )).

#7 @spacedmonkey
4 days ago

Good point @aduth.

I can remove that check.

Note: See TracTickets for help on using tickets.