Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Jun 23, 2021
1 parent bdf7dd6 commit 0f38ae3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ function register_block_style_handle( $metadata, $field_name ) {
$style_handle = generate_block_asset_handle( $metadata['name'], $field_name );
$block_dir = dirname( $metadata['file'] );
$style_file = realpath( "$block_dir/$style_path" );
$version = file_exists( $style_file ) ? filemtime( $style_file ) : false;
$version = ! $is_core_block && $style_file ? filemtime( $style_file ) : false;
$result = wp_register_style(
$style_handle,
$style_uri,
$style_file ? $style_uri : false,
array(),
$version
);
if ( file_exists( str_replace( '.css', '-rtl.css', $style_file ) ) ) {
wp_style_add_data( $style_handle, 'rtl', 'replace' );
}
if ( file_exists( $style_file ) ) {
if ( $style_file ) {
wp_style_add_data( $style_handle, 'path', $style_file );
}

Expand Down
11 changes: 11 additions & 0 deletions src/wp-includes/class-wp-block-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,17 @@ public function set_props( $args ) {

$args['name'] = $this->name;

// Make sure core blocks register a stylesheet.
if ( 0 === strpos( $args['name'], 'core/' ) ) {
$block_name = str_replace( 'core/', '', $args['name'] );
$args['style'] = isset( $args['style'] )
? $args['style']
: "wp-block-$block_name";
$args['editor_style'] = isset( $args['editor_style'] )
? $args['editor_style']
: "wp-block-$block_name-editor";
}

/**
* Filters the arguments for registering a block type.
*
Expand Down

0 comments on commit 0f38ae3

Please sign in to comment.