How to fix broken Admin Styles for Roots Themes

The Fix

In Fall of 2019, WordPress 5.3.0 was released. If you have an old theme built on Roots (Sage before it was redeveloped), then your site backend is a hot mess right now. Thankfully, the fix is easy enough if you can access the theme in an editor.

Either download the theme (do it anyways so that you have a back up) and locate the following file, or go to Themes > Editor (not recommended). Inside of the roots theme, look for the folder lib (short for library). This is the folder that contains sectioned off functions that the functions.php calls.

Inside of the lib folder, open up cleanup.php. The cleanup file is used for removing non-blog related code, or customizing the order/cleanliness of the code. Locate the function roots_clean_style_tag(). This is the function that is causing all the trouble. However, instead of deleting it, simply remove the filter that calls it.

To remove the filter, comment out or delete:

add_filter('style_loader_tag', 'roots_clean_style_tag');

That should be it! the Visual Editor should be working now! If you had a Soil version that is older than 3.7.2, then updating will fix the issue as well.

 

What did I Just Remove?

The function originally filtered all style tags on a site. It would run through the list of link tags and output only those it thought necessary by looking at the media type. The function wont’ let any styles through unless they are print.

Prior to 5.3.0, all the admin styles simply queued the link without setting a media type. Now all Styles are queued with a media type of all and ID’s.