diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index dfcb3d833ef2b..edaa98d7c1fe7 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -4049,65 +4049,65 @@ function wp_trim_words( $text, $num_words = 55, $more = null, $allow_tags = fals $more = __( '…' ); } - $allowed_tags = array( - 'a' => array( - 'class' => array(), - 'style' => array(), - 'href' => array(), - 'id' => array(), - ), - 'strong' => array(), - 'b' => array(), - 'em' => array(), - 'img' => array( - 'class' => array(), - 'style' => array(), - 'src' => array(), - 'alt' => array(), - 'width' => array(), - 'height' => array(), - ), - 'mark' => array( - 'class' => array(), - 'style' => array(), - ), - 'code' => array( - 'class' => array(), - 'style' => array(), - ), - 'kbd' => array( - 'class' => array(), - 'style' => array(), - ), - 'bdo' => array( - 'class' => array(), - 'style' => array(), - 'dir' => array(), - 'lang' => array(), - - ), - 'span' => array( - 'class' => array(), - 'style' => array(), - ), - 'sup' => array( - 'class' => array(), - 'style' => array(), - ), - 'sub' => array( - 'class' => array(), - 'style' => array(), - ), - 's' => array( - 'class' => array(), - 'style' => array(), - ), - ); - + $original_text = $text; if ( $allow_tags ) { + $allowed_tags = array( + 'a' => array( + 'class' => array(), + 'style' => array(), + 'href' => array(), + 'id' => array(), + ), + 'strong' => array(), + 'b' => array(), + 'em' => array(), + 'img' => array( + 'class' => array(), + 'style' => array(), + 'src' => array(), + 'alt' => array(), + 'width' => array(), + 'height' => array(), + ), + 'mark' => array( + 'class' => array(), + 'style' => array(), + ), + 'code' => array( + 'class' => array(), + 'style' => array(), + ), + 'kbd' => array( + 'class' => array(), + 'style' => array(), + ), + 'bdo' => array( + 'class' => array(), + 'style' => array(), + 'dir' => array(), + 'lang' => array(), + + ), + 'span' => array( + 'class' => array(), + 'style' => array(), + ), + 'sup' => array( + 'class' => array(), + 'style' => array(), + ), + 'sub' => array( + 'class' => array(), + 'style' => array(), + ), + 's' => array( + 'class' => array(), + 'style' => array(), + ), + ); $text = wp_kses( $text, $allowed_tags ); - } else { + } else { $text = wp_strip_all_tags( $text ); } $num_words = (int) $num_words;