[wp-trac] [WordPress Trac] #55728: baseURL missing for remotely fetched editor styles

WordPress Trac noreply at wordpress.org
Fri May 13 23:29:40 UTC 2022


#55728: baseURL missing for remotely fetched editor styles
--------------------------+-----------------------------
 Reporter:  strarsis      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  5.9.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Note: I would have created a ticket rather in the Gutenberg repository,
 but the affected code is in the WordPress core.


 When an editor style is added (using `add_editor_style`) as remote URL
 (not as path to a file), the editor style definition from
 `get_block_editor_theme_styles()` passed to the Gutenberg Block Editor
 doesn't contain a `baseURL` field.

 Relevant code:
 https://core.trac.wordpress.org/browser/tags/5.9.3/src/wp-includes/block-
 editor.php#L538

 This missing `baseURL` field prevents the Gutenberg CSS post-processing
 from rewriting the stylesheet-relative URLs inside the CSS, resulting in
 broken `url(...)` references and preview.

 When the `baseURL` is added to remotely fetched styles, too, using the
 known CSS file URL, the URL rewrite issues are fixed and everything looks
 correctly:
 {{{#!php
 <?php
 // [...]
 $styles[] = array(
     'css'            => wp_remote_retrieve_body( $response ),
     'baseURL'        => $style, // added
     '__unstableType' => 'theme',
 );
 // [...]
 }}}

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


More information about the wp-trac mailing list