Make WordPress Core

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#58534 closed enhancement (fixed)

Add Post Content block attributes to block editor settings

Reported by: isabel_brison's profile isabel_brison Owned by: isabel_brison's profile isabel_brison
Milestone: 6.3 Priority: normal
Severity: normal Version: 6.3
Component: Editor Keywords: gutenberg-merge has-patch
Focuses: Cc:

Description

This ticket tracks adding the changes to block editor settings from https://github.com/WordPress/gutenberg/pull/45299 to core, namely the addition of a new setting containing the Post Content block attributes, if they exist.

Currently the main use for this is to access the Post Content layout attribute from the post editor, but it may become necessary to access other attributes such as typography in the future, so it was thought best to add the whole attributes object.

Change History (11)

This ticket was mentioned in PR #4614 on WordPress/wordpress-develop by @isabel_brison.


6 months ago
#1

  • Keywords has-patch added

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

This PR adds the changes from https://github.com/WordPress/gutenberg/pull/45299.

To test, checkout the PR locally and update the "@wordpress/editor" package to its latest version - "13.12.0". Then run the build, and use the Redux dev tools to inspect settings in the state of the core/block-editor store.

@audrasjb commented on PR #4614:


6 months ago
#2

Thanks for the PR!
I added one commit to fix a few coding standards issues :)

@spacedmonkey commented on PR #4614:


6 months ago
#3

Can you please add some unit tests to this PR.

@isabel_brison commented on PR #4614:


6 months ago
#4

Thanks for fixing the coding standards stuff @audrasjb! I'm having issues running the composer scripts locally 😩

I've added a test for the now-renamed wp_get_first_block, now working on tests for _wp_get_post_content_block_attributes.

@isabel_brison commented on PR #4614:


6 months ago
#5

I just added a base test case for _wp_get_post_content_block_attributes to check it returns an empty array by default (if there's no post ID and no block template). Not sure how to test this further, as it requires both a post and its block template to exist. I tried setting $post_ID =1 and switch_theme( 'block-theme' ); but that doesn't seem to work. I'm probably missing something obvious 😅 any help appreciated!

@isabel_brison commented on PR #4614:


6 months ago
#6

Update: I got it working! Had to add a single template to the test block theme.

@isabel_brison commented on PR #4614:


6 months ago
#7

Thanks for the feedback folks!

Question on the tests: I added an extra assertion to test_get_block_editor_settings_theme_json_settings to check for the new setting, and in doing so realised that the test is now relying on the global set above in test_wp_get_post_content_block_attributes to pass. This isn't great as it could also alter results of any tests running after. Do we have any best practices for handling globals in tests? Should they be unset after each test?

@isabel_brison commented on PR #4614:


6 months ago
#8

Do we have any best practices for handling globals in tests? Should they be unset after each test?

Update: @hellofromtonya has pointed me in the right direction and I've updated the tests accordingly.

@mukesh27 commented on PR #4614:


6 months ago
#9

@tellthemachines Re-run the failed job it show Navigation timeout of 30000 ms exceeded .

#10 @isabel_brison
6 months ago

  • Owner set to isabel_brison
  • Resolution set to fixed
  • Status changed from new to closed

In 55955:

Editor: add Post Content attributes to block editor settings.

Adds a new block editor setting containing the Post Content block attributes, if they exist.

Props audrasjb, spacedmonkey, jeremyfelt, mukesh27, flixos90, andrewserong.
Fixes #58534.

@isabel_brison commented on PR #4614:


6 months ago
#11

Thanks again for the reviews, everyone!

Committed in r55955 / b35b1fc.

Note: See TracTickets for help on using tickets.