WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/21/2020 11:37:30 AM (2 months ago)
Author:
gziolo
Message:

Blocks: Align with Gutenberg the name of generated asset handle for core blocks

Related Gutenberg PR: https://github.com/WordPress/gutenberg/pull/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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r49695 r49850  
    7272 */
    7373function generate_block_asset_handle( $block_name, $field_name ) {
     74    if ( 0 === strpos( $block_name, 'core/' ) ) {
     75        $asset_handle = str_replace( 'core/', 'wp-block-', $block_name );
     76        if ( 0 === strpos( $field_name, 'editor' ) ) {
     77            $asset_handle .= '-editor';
     78        }
     79        return $asset_handle;
     80    }
     81
    7482    $field_mappings = array(
    7583        'editorScript' => 'editor-script',
Note: See TracChangeset for help on using the changeset viewer.