[wp-trac] [WordPress Trac] #54993: Inline output using wp_enqueue_block_style adds unnecessary paths

WordPress Trac noreply at wordpress.org
Sun Jan 30 04:44:07 UTC 2022


#54993: Inline output using wp_enqueue_block_style adds unnecessary paths
--------------------------+-----------------------------
 Reporter:  s56bouya      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.9
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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
 <?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?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54993>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list