Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register 'lock' attribute for every block on the server #2615

Closed

Conversation

Mamaduka
Copy link
Member

Backports changes from WordPress/gutenberg#40468.

The lock attribute needs to be supported by every block, but currently, it is only done on the client site. As a result, it was causing block rendered API requests to fail when blocks are locked.

PR updates the WP_Block_Type class to handle built-in/core attribute registration.

Trac ticket: https://core.trac.wordpress.org/ticket/55567

cc @gziolo, @hellofromtonya


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@Mamaduka Mamaduka changed the title Fix/register lock attribute on server Register 'lock' attribute for every block on the server Apr 21, 2022
* @since 6.0.0
* @var array
*/
const CORE_ATTRIBUTES = array(
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't decide between CORE_ATTRIBUTES and BUILTIN_ATTRIBUTES. I'm open to name suggestions :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't decide between CORE_ATTRIBUTES and BUILTIN_ATTRIBUTES.

How about GLOBAL_ATTRIBUTES or GLOBAL_BLOCK_ATTRIBUTES?

Copy link
Member

Choose a reason for hiding this comment

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

GLOBAL_ATTRIBUTES reads nice 👍🏻

@Mamaduka
Copy link
Member Author

The issue is from WP 5.9, but it's more visible now that we have UI.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I've added a few notes inline, mainly in the tests to use more precise assertions and add the ticket number to the docblocks.

* @since 6.0.0
* @var array
*/
const CORE_ATTRIBUTES = array(
Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't decide between CORE_ATTRIBUTES and BUILTIN_ATTRIBUTES.

How about GLOBAL_ATTRIBUTES or GLOBAL_BLOCK_ATTRIBUTES?

src/wp-includes/class-wp-block-type.php Outdated Show resolved Hide resolved
tests/phpunit/tests/blocks/wpBlockType.php Show resolved Hide resolved
tests/phpunit/tests/blocks/wpBlockType.php Outdated Show resolved Hide resolved
tests/phpunit/tests/blocks/wpBlockType.php Outdated Show resolved Hide resolved
tests/phpunit/tests/blocks/wpBlock.php Outdated Show resolved Hide resolved
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
@gziolo
Copy link
Member

gziolo commented Apr 25, 2022

Let's plan to land this patch tomorrow before WP 6.0 Beta 3. I see two remaining tasks:

  • CORE_ATTRIBUTES -> GLOBAL_ATTRIBUTES
  • setup for attributes should happen before the register_block_type_args filter

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Awesome, this is in great shape. I will take care of committing to WP core 👍🏻

@gziolo
Copy link
Member

gziolo commented Apr 26, 2022

Committed with https://core.trac.wordpress.org/changeset/53268.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants