Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/wp-includes/blocks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ function register_core_block_style_handles() {
return;
}

$includes_url = includes_url();
$includes_path = ABSPATH . WPINC . '/';
$suffix = wp_scripts_get_suffix();
$wp_styles = wp_styles();
$style_fields = array(
$blocks_url = includes_url( 'blocks/' );
$suffix = wp_scripts_get_suffix();
$wp_styles = wp_styles();
$style_fields = array(
'style' => 'style',
'editorStyle' => 'editor',
);

static $core_blocks_meta;
if ( ! $core_blocks_meta ) {
$core_blocks_meta = require $includes_path . 'blocks/blocks-json.php';
$core_blocks_meta = require BLOCKS_PATH . 'blocks-json.php';
}

$files = false;
Expand All @@ -68,10 +67,10 @@ function register_core_block_style_handles() {
}

if ( ! $files ) {
$files = glob( wp_normalize_path( __DIR__ . '/**/**.css' ) );
$files = glob( wp_normalize_path( BLOCKS_PATH . '**/**.css' ) );
$files = array_map(
static function ( $file ) use ( $includes_path ) {
return str_replace( $includes_path, '', $file );
static function ( $file ) {
return str_replace( BLOCKS_PATH, '', $file );
},
$files
);
Expand All @@ -88,9 +87,9 @@ static function ( $file ) use ( $includes_path ) {
}
}

$register_style = static function( $name, $filename, $style_handle ) use ( $includes_path, $includes_url, $suffix, $wp_styles, $files ) {
$style_path = "blocks/{$name}/{$filename}{$suffix}.css";
$path = wp_normalize_path( $includes_path . $style_path );
$register_style = static function( $name, $filename, $style_handle ) use ( $blocks_url, $suffix, $wp_styles, $files ) {
$style_path = "{$name}/{$filename}{$suffix}.css";
$path = wp_normalize_path( BLOCKS_PATH . $style_path );

if ( ! in_array( $style_path, $files, true ) ) {
$wp_styles->add(
Expand All @@ -100,7 +99,7 @@ static function ( $file ) use ( $includes_path ) {
return;
}

$wp_styles->add( $style_handle, $includes_url . $style_path );
$wp_styles->add( $style_handle, $blocks_url . $style_path );
$wp_styles->add_data( $style_handle, 'path', $path );

$rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $path );
Expand Down