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

Fix block editor stylesheet being registered with wrong URL #4679

Conversation

felixarntz
Copy link
Member

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

This PR also includes test coverage for the core-specific code paths of register_block_style_handle() which was missing before.


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.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

One nitpick, but looks good to me.

src/wp-includes/blocks.php Outdated Show resolved Hide resolved
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @felixarntz for the PR. Just a couple driveby nits.

src/wp-includes/blocks.php Outdated Show resolved Hide resolved
tests/phpunit/tests/blocks/register.php Show resolved Hide resolved
tests/phpunit/tests/blocks/register.php Outdated Show resolved Hide resolved
Comment on lines +334 to +335
$metadata_file = ABSPATH . $block_json_path;
$metadata = wp_json_file_decode( $metadata_file, array( 'associative' => true ) );
Copy link
Member

Choose a reason for hiding this comment

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

instead of loading the metadata like this, by not use the parsed php?

see

Suggested change
$metadata_file = ABSPATH . $block_json_path;
$metadata = wp_json_file_decode( $metadata_file, array( 'associative' => true ) );
$core_blocks_meta = require ABSPATH . WPINC . '/blocks/blocks-json.php';
$metadata = $core_blocks_meta[$block_name];

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 think for tests that doesn't really matter. The block.json file is the source of truth while blocks-json.php is a built file, so I think for tests relying on block.json is a more reliable approach.

@felixarntz
Copy link
Member Author

@felixarntz felixarntz closed this Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants