Remove empty lines ( ) when author updates their post

Whenever adding an empty line between paragraphs using TinyMCE, the   character entity is added.

How can I strip the content of all instances of this character whenever an author updates their post (save_post)?

2 Answers
2

Figured it out, hooking into content_save_pre:

function remove_empty_lines( $content ){

  // replace empty lines
  $content = preg_replace("/ /", "", $content);

  return $content;
}
add_action('content_save_pre', 'remove_empty_lines');

Leave a Comment