Skip to content

Commit

Permalink
Blocks: Align with Gutenberg the name of generated asset handle for c…
Browse files Browse the repository at this point in the history
…ore blocks

Related Gutenberg PR: WordPress/gutenberg#25220.

It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged.

Props aristath.
See #50328.


Built from https://develop.svn.wordpress.org/trunk@49850


git-svn-id: https://core.svn.wordpress.org/trunk@49569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
gziolo committed Dec 21, 2020
1 parent 9541225 commit 0576f84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ function remove_block_asset_path_prefix( $asset_handle_or_path ) {
* @return string Generated asset name for the block's field.
*/
function generate_block_asset_handle( $block_name, $field_name ) {
if ( 0 === strpos( $block_name, 'core/' ) ) {
$asset_handle = str_replace( 'core/', 'wp-block-', $block_name );
if ( 0 === strpos( $field_name, 'editor' ) ) {
$asset_handle .= '-editor';
}
return $asset_handle;
}

$field_mappings = array(
'editorScript' => 'editor-script',
'script' => 'script',
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49849';
$wp_version = '5.7-alpha-49850';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 0576f84

Please sign in to comment.