• Hi,

    I’ve now searched for long time, hoping to find a solution.

    Sometimes there are non-breaking spaces ( ) in content that users paste to the editor.

    I would like to highlight these non-breaking spaces for logged in users or in the backend.
    For this it would be necessary to add a class.

    What I found is wordpress.org/support/topic/can-you-select-non-breaking-spaces-in-css.

    This solution works like a charme for <p>&nbsp;</p> even when I change it to

    function user_content_replace ( $content ) {
    	return str_replace('&nbsp;', '<span class="highlight">&nbsp;</span>', $content);
    }
    add_filter ('the_content', 'user_content_replace', 99);

    But it doesn’t work at all in nonempty paragraphs as e.g. <p>test&nbsp;test</p>.

    Like this a solution would be very appreciated!

    Thank you in Advance
    Bernhard

  • The topic ‘select non-breaking spaces for formatting with CSS’ is closed to new replies.