Skip to content

Instantly share code, notes, and snippets.

@willybahuaud
Created December 14, 2017 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willybahuaud/4c6772031d056d0202f3a8915aa5b45a to your computer and use it in GitHub Desktop.
Save willybahuaud/4c6772031d056d0202f3a8915aa5b45a to your computer and use it in GitHub Desktop.
<?php
add_filter( 'the_title', 'willy_insert_missing_unsecable' );
add_filter( 'the_content', 'willy_insert_missing_unsecable' );
function willy_insert_missing_unsecable( $text ) {
$patterns = array(
'« ' => '«&nbsp;',
' »' => '&nbsp;»',
' :' => '&nbsp;:',
' !' => '&nbsp;!',
' ?' => '&nbsp;?',
' ;' => '&nbsp;;',
);
return str_replace( array_keys( $patterns ), array_values( $patterns ), $text );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment