[wp-trac] [WordPress Trac] #26842: Contenteditable, multiple spaces,  , and U+00A0
WordPress Trac
noreply at wordpress.org
Mon Jan 29 15:17:00 UTC 2018
#26842: Contenteditable, multiple spaces,  , and U+00A0
------------------------------+-----------------------------
Reporter: azaozz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: TinyMCE | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-unit-tests | Focuses:
------------------------------+-----------------------------
Comment (by y0uri):
Replying to [comment:23 CK MacLeod]:
> The following function works, but, like most of the other fixes proposed
on other threads, or that you can find around the Web - some focusing on
WP php functions, some on tinyMCE or other Javascript methods - it doesn't
allow users who want non-breaking spaces to keep them:
>
> {{{
> add_filter( 'content_save_pre', 'remove_buggy_nbsps', 99 );
>
> function remove_buggy_nbsps( $content ) {
>
> return str_replace( '\xc2\xa0', ' ', $content);
>
> }
> }}}
>
> It could be improved upon in various ways, no doubt, but, like I said,
it works.
It only works if you replace these single quotes by double quotes, ie.:
{{{
return str_replace( "\xc2\xa0", ' ', $content);
}}}
Thanks for this fix btw. It was messing things up in another system that
depends on a WP feed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26842#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list