Opened 6 weeks ago
Last modified 5 weeks ago
#65603 new defect (bug)
Additional CSS cleared in multisite setup when user is admin on single site
| Reported by: | launchinteractive | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | administration, multisite |
Description
I have a multisite setup. The global admin can add Additional CSS to a block but when a user edits the page that isn't a global admin the Additional CSS disappears.
Change History (2)
#2
@
5 weeks ago
That all makes sense and I see why it has been built this way.
My preference would be for WordPress to preserve unchanged CSS. My client didn't read the notice and was wondering why it all changed. I didn't actually notice it myself when I was debugging the issue.
For now I have created a simple plugin that grants them the right capability.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
After digging in, I think what's happening here is largely intentional, and I want to lay it out so we can confirm the expected behavior together.
1. A non-super-admin not seeing the "Additional CSS" field is by design.
Block-level custom CSS is gated behind the
edit_csscapability, which is an alias ofunfiltered_html. In multisite,unfiltered_html/edit_cssis granted only to super admins (and it's denied to everyone whenDISALLOW_UNFILTERED_HTMLis set). The block editor only exposes the Additional CSS control when the current user has that capability (canEditCSS). So a regular site Administrator not being able to author or edit custom CSS is consistent with howunfiltered_htmlhas always worked in multisite.2. The Gutenberg editor already warns before the CSS is removed — this is also by design.
When such a user opens a post that already contains block custom CSS, the editor surfaces this notice:
So the removal isn't silent data loss — the user is told up front that saving will strip CSS they aren't permitted to edit. On save, the
edit_css-gated filter added in #64771 removes thestyle.cssblock attributes accordingly. Both the capability gate and the pre-save warning are working as intended.3. To confirm from team
Given the above, the remaining question is whether this is the desired end state or whether we want to soften it. As I see it:
unfiltered_html-level privileged; a non-super-admin editing the post can't retain CSS they can't see or edit, and the warning makes the consequence explicit. If this is the intended posture, this can likely be closed aswontfix/documented, and we should make sure the behavior is already covered in the docs.wp_insert_post_data), and would have to compare CSS values rather than block position to handle reordering and duplicated blocks.My take is that the current behavior (gate + warning + strip) is internally consistent, so my inclination is toward "accept as designed" unless there's scope for the preserve-unchanged approach. Could any maintainer clarify the direction?