Make WordPress Core

Opened 3 years ago

#55728 new defect (bug)

baseURL missing for remotely fetched editor styles

Reported by: strarsis's profile strarsis Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9.3
Component: Editor Keywords:
Focuses: Cc:

Description

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
// [...]
$styles[] = array(
    'css'            => wp_remote_retrieve_body( $response ),
    'baseURL'        => $style, // added
    '__unstableType' => 'theme',
);
// [...]

Change History (0)

Note: See TracTickets for help on using tickets.