Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#54993 new defect (bug)

Inline output using wp_enqueue_block_style adds unnecessary paths

Reported by: s56bouya's profile s56bouya Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9
Component: Script Loader Keywords:
Focuses: Cc:

Description

Outputting inline using wp_enqueue_block_style, adds an unnecessary path to the CSS property. I want to delete it.

CSS

.wp-block-button{
	mask:url("data:image/svg+xml;base64,iRxVB0…");
}

PHP

Refer to (https://make.wordpress.org/core/2021/12/15/using-multiple-stylesheets-per-block/)

<?php
add_action( 'after_setup_theme', function() {
    // Same args used for wp_enqueue_style().
    $args = array(
        'handle' => 'my-theme-buttons',
        'src'    => get_theme_file_uri( 'assets/blocks/buttons.css' ),
    );
 
    // Add "path" to allow inlining asset if the theme opts-in.
    $args['path'] = get_theme_file_path( 'assets/blocks/buttons.css' );
 
    // Enqueue asset.
    wp_enqueue_block_style( 'core/buttons', $args );
} );

Result

Output inline.

<style id='my-theme-buttons-inline-css'>
.wp-block-button{
	mask:url("/wp-content/themes/abc/assets/blocks/data:image/svg+xml;base64,iRxVB0…");
}
</style>

The path

/wp-content/themes/abc/assets/blocks/

is not needed. I want to delete it. Is there any solution? Or is it a bug?

Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Script Loader
Note: See TracTickets for help on using tickets.