txt_brk

mail@pastecode.io avatar
unknown
php
2 years ago
586 B
4
Indexable
Never
// ----------------------------------------------------------------------------------------------
// 18 - ZALAMOVÁNÍ TEXTU
// ----------------------------------------------------------------------------------------------
add_filter( 'the_content', 'dg_automatic_nbsp' );
add_filter( 'the_excerpt', 'dg_automatic_nbsp' );
function dg_automatic_nbsp( $content ) {

if (!is_admin()) {
      $content =  preg_replace("#(?:^|(?=\s))(.{1,3})(\s)+#i", "$1 ", $content);
      return str_replace("<a&nbsp;","<a ",$content);

      }
else {
      return $content;
    }
}