WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 11 months ago

#38549 new enhancement

Additional CSS lost when changing themes

Reported by: scottwyden Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords:
Focuses: Cc:

Description

When you change themes, the Additional CSS is lost. Change the theme back and it returns. I think there should be an option to retain the Additional CSS across any theme used. If we do not implement that, I have a funny feeling that many users will be confused as to where their custom CSS went.

Change History (11)

#1 follow-up: @lukecavanagh
12 months ago

@scottwyden

So an option to copy over the CSS when changing themes to the new theme maybe?

#2 in reply to: ↑ 1 @scottwyden
12 months ago

Replying to lukecavanagh:

@scottwyden

So an option to copy over the CSS when changing themes to the new theme maybe?

That would be sufficient in my opinion, yes.

#3 @westonruter
12 months ago

Instead of there being an option to push the CSS into another theme when switching, it would probably be preferred to have a dropdown to pull CSS from another theme. So if you're editing a twentyseventeen child theme you there could be a dropdown for importing CSS from twentyseventeen parent theme.

Aside: the CSS pulled from the other theme would need to first check the current changeset to see if there are any CSS changes for that theme stored in it, and if so, use those instead of the changes in the custom_css post type for that theme.

I'm not 100% sure this is a defect. It seems more like an enhancement.

#4 @georgestephanis
12 months ago

There could be some mitigation w/r/t if someone changes to a parent theme or a child theme, retaining the existing styles as well.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


12 months ago

#6 @lukecavanagh
12 months ago

Or maybe CSS that is marked global, could be copied over for the custom CSS when the theme is changed. But then you would need a way to define CSS as being global, as in this CSS changes how this plugin is displaying on the front-end, or this element is being hidden.

This ticket was mentioned in Slack in #core by helen. View the logs.


11 months ago

#8 @helen
11 months ago

  • Type changed from defect (bug) to enhancement

The two most common existing custom CSS solutions out there are ones that are bundled with themes and Jetpack, neither of which persist CSS between theme changes. I'm a pretty heavy user of custom CSS myself, and while occasionally I like to go back and see what I had before, I've never wanted to wholesale import it over with a theme change, as the selectors are often quite different and I tend to have made changes that are very theme-specific, as CSS really should be for the most part. Even if it's for a plugin, it's usually scoped to some selector within the theme.

#9 follow-up: @lukecavanagh
11 months ago

@helen 

But certain custom CSS would be related specifically to an active plugin and not the active theme.

#10 in reply to: ↑ 9 @helen
11 months ago

Replying to lukecavanagh:

But certain custom CSS would be related specifically to an active plugin and not the active theme.

Right, hence occasionally finding it useful to refer back to what I had. But not importing it wholesale:

Even if it's for a plugin, it's usually scoped to some selector within the theme.

(And styled to go with the theme.)

#11 @lukecavanagh
11 months ago

@helen 

What about a warning message or notification to the user, if they do have CSS stored in the custom CSS and are going to change active themes. Something to the effect, your custom CSS will be lost if you are changing themes.

Note: See TracTickets for help on using tickets.