Make WordPress Core

Changes between Version 3 and Version 4 of Ticket #26842, comment 24


Ignore:
Timestamp:
03/24/2017 02:37:50 AM (10 years ago)
Author:
CK MacLeod

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26842, comment 24

    v3 v4  
    11Replying to [comment:23 CK MacLeod]:
    22
    3 Just wanted to correct some misinformation in my prior comment. The function that will remove the code from post content on save is the following (variations with wp_insert_post_data) also work:
     3Just wanted to note I've corrected some misinformation in my prior comment (the code was wrong).
    44
    5 While this thread was still open, I just wanted to correct my prior answers. I've gone into more detail here - https://ckmacleod.com/2017/03/23/exterminating-non-breaking-space-bug/ - but, in short, the snippet that I gave previously just happens to work, in effect by coincidence, if you have Next Generation Gallery installed - very complicated. Also, the problem isn't "hexadecimal," though is on the level of character encoding.
     5I've gone into more detail here - https://ckmacleod.com/2017/03/23/exterminating-non-breaking-space-bug/ - but, in short, the snippet that I gave previously just happened to work, more or less by coincidence, if you have Next Generation Gallery installed (long story). And I'm still not sure I've stated the underlying character-encoding problem correctly.
    66
    7 What will work to get rid of bad non-breaking spaces of the type being discussed here is the following function:
     7More at Exterminating the Non-Breaking Space Bug[https://wp.me/p4h0Xw-gGR], including ways to deal with already-archived posts and to exclude certain types of post.
    88
    9 
    10 {{{
    11 add_filter( 'content_save_pre', 'remove_buggy_nbsps', 99 );
    12 
    13 function remove_buggy_nbsps( $content ) {
    14 
    15    return str_replace( '\xc2\xa0', ' ', $content);
    16 
    17 }
    18 }}}
    19 
    20 
    21 Because the problem relates to UTF-8 character code in the database. More at Exterminating the Non-Breaking Space Bug[https://wp.me/p4h0Xw-gGR], including ways to deal with already-archived posts and to exclude certain types of post.
    22 
    23 The code used on another thread (at [https://core.trac.wordpress.org/ticket/31157#comment:5] )also works - though I don't see why it would be preferable:
     9I'll also note that the code used on another thread (at [https://core.trac.wordpress.org/ticket/31157#comment:5] )also works - though I don't see why it would be preferable:
    2410
    2511
    … …  
    3824});
    3925}}}
    40 The above actually relates to the peculiar feature of Next Generation Gallery plug-in (buried deep in its code) that served to enable the prior function - that uses
    41 {{{
    42  
    43 }}}
    44  instead of
    45 {{{
    46 \xc2\xa0
    47 }}}
    48 and worked.
    49 
    50 Long story. As noted in the linked post, there is also a needfor dealing with posts already saved with the unwanted nbsps. My main purpose here is just not to leave my mistake from months ago uncorrected, since I know that people like me looking for solutions often arrive at threads like this one looking for answers.
     26The above actually relates to the peculiar feature of Next Generation Gallery plug-in (buried deep in its code) that served to enabled the function that worked by coincidence. My main purpose here is just not to leave my mistake from months ago uncorrected, since I know that people like me looking for solutions often arrive at threads like this one looking for answers.