I cannot offer a JavaScript solution, because I am not sure where exactly this is happening.
But … we can hook into wp_insert_post_data
and solve this issue in PHP:
add_filter( 'wp_insert_post_data', 't5_strip_double_spaces', 20 );
function t5_strip_double_spaces( $data )
{
$data['post_content'] = preg_replace(
"~( \x{C2}\x{A0}|\x{C2}\x{A0} )~m",
' ',
$data['post_content']
);
return $data;
}
As plugin on GitHub.
Related Posts:
- How to detect single.php (but not single-portfolio.php)?
- Changing the post date and time with function
- Get current post id in functions.php
- Dynamically add id to heading tags
- disable WP automatically inserted line breaks after an image
- Getting the post_id in wp_ajax function
- How to publish a post with empty title and empty content?
- delete post also attachments
- Remove hidden formatting when user paste text from MS Word into TinyMCE
- How to call function within a page/post, to dynamically generate content?
- Restrict users from editing post based on the age of the post
- How do I use element instead of tags in WordPress post content having webP support?
- Change padding to text indent in “Increase indent” TinyMCE
- Is there a WordPress equivalent to MediaWiki templates
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Human Time Diff, change mins to minutes
- How to get new post URL?
- Force update all posts in custom post type, no content changes
- Remove whitespace at the end of posts?
- Disable REST API for a user ROLE
- How to display post tags
- How to Display Post View Count
- Add confirmation popup on “Move to Trash”
- Allow role to delete posts but block him the wp-admin
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- $post object is null
- How to change the page break URL from ../post/2 to …/post/page2/
- How to add a custom field after wp post
- How can I list random authors from current post category?
- Disable single post page
- Enabling post thumbnails for custom post type
- Remove permalink from images when inserting into post
- Getting current post ID in functions.php
- Prepend or add an Image to the content of a Post
- Load post attached images on a single page site with fancybox
- Format the Layout of Images In The Edit Post Textarea?
- Exclude category from
- Setting posts_per_page for taxonomy term template
- Change post order random through out the entire WordPress
- How to display the link (title) and thumbnail post?
- How to do set post permalinks using 6 digit random unique function?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Send post id through ajax and get the post content back
- Change all author links in Blog roll
- disable Tab post on nav-menus page (Admin)
- Adding bootstrap classes to video shortcodes
- Every second post different class in blog view
- Format latest/newest post differently
- is_page Funtion for Posts ?
- Get post meta retrieving wrong value
- The_excerpt() doesn’t parse – how to change that?
- How to only publish posts with image in it
- Add custom text automatically on each post
- Getting Whitescreen when publishing a post [closed]
- Using system date format
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- saving/reading custom field value does not work – no value gets POSTed
- Same post appears in related Posts?
- Internal linking to posts permalink fail because of spaces and stripe at postname
- How to determine if a post was last edited in the Visual Editor
- Right align a youtube video
- Help on conditional statement to accompany wp_insert_post function please?
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- how to show comments only author which send own posts in wordpress
- get category in list of posts // shortcode for custom related posts
- shortcode // get posts by ids
- Alt text attributes not showing over portfolio images
- Find most used words in post titles
- $post->post_content empty while all other properties are correct
- Set a post expiration and delete a post when expirate
- I want to change the WordPress comments file
- Replace Tag Keyword With Link Within Post Content
- AJAX load more posts not using correct category and repeating the same few posts
- Get post id outside loop : Notice: Trying to get property of non-object
- How to allow some visitors to edit inline specific post
- How to correctly escape data
- Trim excerpt to first paragraph
- im trying make a function to auto correct posts when i open the posts in the backoffice
- How to change number of posts shown on homepage vs other pages?
- Show only top 3 posts from 3 categories in order on home page
- How to get posts from network blog
- When I click edit on a post, all the content disappear. Does anyone know how to fix this?
- Get post title by Alphabet
- How can I create a menu items from meta box based on users input
- How to use wp_editor(); in functions.php then retrieve content in the template
- List direct children of page
- How *not* to show the last post on the latest posts list
- save_post not working
- Display a custom field rating system in the front end
- wp trim function not working
- Insert Shortcode exactly at the end of the content
- Ajax calls in wordpress
- display last post modified date in genesis child themes
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- Show Next/Previous without Link
- How to use shortcode to get the second to newest post?
- How to sort posts alphabetically based on a specific parent category