The new rich Text Widget in WordPress 4.8 is stripping out code. Get the skinny on what to do for your site and the changes being made to the Text Widget.
See details and links below the video
Text Widget Bug
The new rich Text Widget is stripping out some HTML code.
That’s wreaking havoc for site owners that have certain types of custom coding.
The bug report was posted 5 days ago, citing the specific code types that are being stripped out.
Stripped code types include:
- empty span tags
- empty a href tags, where a class from the css.style sheet is being called
- some javascript tags
How to Avoid Issues Now
If you haven’t updated to WordPress 4.8 yet, don’t.
A fix is in the works, more on that in a moment.
If you have updated to WordPress 4.8, don’t open your Text Widgets!
Opening them and/or flipping between the Visual and Text view mode is what strips out the code, even if you don’t Save the changes.
The problem is that the Text Widget opens by default into the Visual view mode, and whoosh, your custom coding may be stripped.
If you run ads in your widgets, the code there is likely javascript and may be affected. Contact your ad network to get the latest news from them about whether this change will affect you.
Temporary Fixes
Christina of Christina Creative Design forked the original Text Widget code into a new plugin called Classic Text Widget.
Prior to updating to WP 4.8, you can copy all of the code from your current Text Widgets into this one and your code will remain intact.
The caveat with using this plugin is, it’s a painfully slow, manual process for a temporary fix.
You might just want to wait for an update to WordPress, which is already happening.
What’s Next?
The bug report has a lengthy discussion with all manner of ideas for how the WP devs should fix this.
Fix ideas include:
- Putting the Text Widget back to standard and creating a new Rich Text Widget
- Creating a new HTML Widget
- Renaming the original Text Widget as HTML Widget and leaving the rich Text Widget in its current state
The discussion includes:
- a push to fix this in the least destructive and time-consuming manner for site owners.
- a way to guarantee the preservation of code currently in the Text Widget, whether site owners have updated or not
Keep in mind that all of the new widgets in WP 4.8 required a ground up rebuild.
There were bound to be issues.
Unfortunately, not enough of the folks who have time to enter into the bug report discussion had time to test the two release candidates before WP 4.8 was released publicly, so here we are.
I did test the release candidates, but I always have well formatted code in my widgets, or don’t use the other types of code that is getting stripped out.
Update in the Works
An update to WP 4.8 is in the works already.
We just don’t know which of the above suggested fixes they are going to take.
I assume it will be a balance of how much code has to change, and how much that will affect future feature updates in WordPress, balanced with how much trouble this is going to be for end users to make the switch.
Stay Up to Date
Be sure to catch me live, or see my video updates for BlogAid Today on
Turn on notifications to know when I go live!!
Subscribe to BlogAid News and my blog posts to get breaking news, events, and Tips Tuesday posts.
I unfortunately ran into this issue AFTER updating, so I have no way to dump my widget content into another type of widget before updating. I did find a workaround using a shortcode plugin called shortcoder.
I was able to paste all the HTML content into new shortcodes (which do not get messed with) and then use the shortcodes in the widget editor. It’s not elegant but it works.
I did have to fix any of the ones that were in the Visual editor, but I was able to scrape the old values from the site as long as I hadn’t saved over them.
Thanks for letting us know Nicholas. One of my webmasters mentioned shortcoder plugin as well, but I didn’t have the details on it. So sorry you ran into this issue. I hope they get it resolved soon.
Another fix that may also work long term is to use the Enhanced Text Widget: https://wordpress.org/plugins/enhanced-text-widget/
It hasn’t been updated it some time, but it still works. I have been using it for over 3 years , and it an outstanding plugin. I have upgraded to 4.8 and there is no problem with it.
Not clear why something like this is not already in WP.
Thanks for the alternative fix, Rick. There are several things available in plugins that I’m mystified about why they aren’t in the core. Chief among them is the ability to write well formatted code in the text editor. The TinyMCE Advanced plugin allows for that. And it’s dev, Andrew Ozz, is on the WP core dev team too.
The main issue I found was the adding of P tags automatically.
So for instance if you have a blank line in a script ( e.g. the way Google Analytics give you by default ) you get P tags in the scripts.
I don’t think you are quite correct, as in when you first open the widget it is in Visual Mode and you can’t see you custom code, so you think it is wiped out – but it isn’t, switch to text and its is there. The problem is switch back to visual and the code gets stripped. You have identified the key items.
WordPress are now thinking about creating a new Widget HTML only ( like the classic ) but I don’t think they want to revert.. But maybe they will change some of the code stripping.
Meanwhile, for my purposes, I like not adding P tags, so I created a plugin that adds back teh check box
https://wordpress.org/plugins/add-paragraphs-option-to-text-widget/
Alan, from what I’ve read, experiences vary with what gets stripped out and how. I reported what others are reporting that they’ve seen with the type of code they use.
I’m sure they are working hard on the best way to resolve this with the least pain, at least I hold that faith.
That’s a nice plugin you have, in case folks want to go that direction.
The only way I found to work around the problem at the moment is to open it. Go into text mode: copy the code; paste it into a text editor; remove the and code; make the changes; paste it back in text mode and save. The easiest way is to use a good code editor like sublime text where you can search and replace text….
That sure is a lot of manual labor, Chris. I hope they get it fixed soon, or at least let us know they are working on it.
This little fix was added but @gitlost on the text widget TRAC ticket to restore the previous behaviour after updating to 4.8, will leave it here if anyone was looking for it:
https://github.com/gitlost/ye-olde-text-widget
Hi Tony, thanks for including that link. I had mentioned this fix in a previous Tips Tuesday, but it’s not easy for non tech site owners to implement. I sure hope they get this fixed in core!!!!
Thanks for your help, this has been driving me crazy over the past week. Hopefully a new update will fix things!
I sure hope so too, NicK. I don’t see that they are in any hurry about it, though.
If there are any Yootheme users out there, don’t upgrade to 4.8. The default setting for the widget visual editor totally breaks code upon opening. The problem is that by the time you switch to text editing, the code is already broken, so you can’t copy and paste to salvage anything. I had to restore an old backup to continue working on one of my clients sites. I’m baffled over why WordPress did this.
Thanks for the heads up on the Yootheme, James. I’m sure a LOT of other themes are having the same issues.
This just goes to show why more folks need to jump into the beta tests before big core changes like this are released. I didn’t run into any code stripping issues when I tested, but then there are lots of code types that folks have in widgets, and lots of other themes. We need more testers!!!!
This is also a reason why I want a version of WordPress that doesn’t receive any of these ridiculous updates that are designed for people who don’t know how to program. I do not need my WordPress to start functioning like Wix…I am better than that. It is almost as if they are trying to create a program that thinks it is smarter than the programmers. If it isn’t broken, don’t fix it. All I want is stable version that updates every 6 months….if that.
That would be nice Daniel. But devs are outnumbered by the millions when it comes to site owners. And they are demanding the type of Wix interface and the direction that WP is going.
The main complaint a lot of site owners have now is the myth that WP is easy. It was 5 years ago, but isn’t any more. And the cost of owning a site has gone through the roof, especially for non techie folks. Lots of them getting ripped off more now too.
Hi MaAnna. I have also noticed some else even more irritating with the new 4.8 update – specifically for WOOCOMMERCE if you are using any product custom fields that have HTML content:
– Its stripping out any ” or ‘ found in some cases. In other cases it is adding te infamous \, then converting the quote to HTML equivalent.
– if you try to load IMG SRC or AHREF or anything that commonly contains ” to define the image or link, it is stripping the URL out completely!
– if you try to load an A HREF with a target without quotes, WP adds the quotes back on it. But next time you edit the product record if you forget to remove those quotes again, it will do one of the above.
– its the worst with custom fields that have an editor in admin, but it is also doing it with just basic custom fields.
This couldnt have come at a worse time, as we just helped a client launch a major WOOCOMMERCE site with WC FIELDS FACTORY, WP TABS PRO, and some other items. Before the update you could load anything you wanted into those fields and it would retain it. Now I have had to explain to the client its a bug that was introduced, which is putting all of their product updates on us since they dont have the experience needed for HTML tweaking.
Since this wasn’t an issue before, I am guessing its related to the update. If you have any advice on this, it would be greatly appreciated!
Oh, that’s just nasty Bruce!!!!! Especially now that you have to do all the updates manually. Sure takes the excitement out of having a new site launched!!!
I’ll pass this on to my webmasters, some of whom work with Woo a lot, and see if they have any ideas for you.
I have custom code in my text widgets that creates overlay hover effects. The new WordPress version wreaks havoc on this code and my clients have been less than enthusiastic with the resulting mess. I found a site that guides you through a “downgrade” process so that you can go back to an older version of WordPress. I have tried it on one of my websites. It worked fine for me.
Here is the link: http://dominiquej.com/how-to-downgrade-wordpress-to-previous-version/
Once WordPress comes up with a fix for this mess, I will re-upgrade it again.
Don’t forget to add the plugin to stop automatic updates – or – add this line to your wp-config.php file:
define( ‘WP_AUTO_UPDATE_CORE’, false );
The above line of code keeps your site from automatically updating WordPress.
Thanks Rosie! I’m sure everyone is scrambling to find ways to deal with this temporarily. Downgrading the WP version is a big deal, and not sure all site owners are up to that task. But, at least there is a tutorial.
I’m not sure the update line is necessary, unless you’re on a managed host that auto updates no matter what. Folks on regular hosting would not have experienced an auto update from 4.7.x to 4.8. But, everyone that has already updated to 4.8 is going to experience the update to 4.8.1 if they don’t turn that off.
I can’t say that I’m keen on the way it looks like they have chosen to fix this. So, we’ll see.
Hi,
I use the plugin black Studio TinyMCE widget
A lot of my clients use that plugin too. At least it will work as long as TinyMCE is supported in WP, which I think it will continue to be, even after Gutenberg launches.