Make WordPress Core

Ticket #64944: br-spacing-fix.diff

File br-spacing-fix.diff, 460 bytes (added by addiestavlo, 3 months ago)

<br> tags are stripped without preserving spacing, causing words to concatenate (e.g., ‘thisexample’). This replaces <br> with a space before tag stripping to preserve word boundaries. Note tags are already stripped just after this, and newlines, returns, spaces, etc. are all later used to create the $words_array here. This helps retain expected generated excerpt behavior when using verse and paragraph (w/ shft+space) type blocks.

  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index 2b32b5aafb..e59bcbc5fe 100644
    a b function wp_trim_words( $text, $num_words = 55, $more = null ) { 
    40524052        }
    40534053
    40544054        $original_text = $text;
     4055        $text          = preg_replace( '/<br\b[^>]*\/?>/i', ' ', $text );
    40554056        $text          = wp_strip_all_tags( $text );
    40564057        $num_words     = (int) $num_words;
    40574058