-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Block] Display paragraph breaks in comment contents block. #40667
Conversation
str_replace( array( "\n", "\t" ), '', '<ol ><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread-even depth-1"><div class="wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content"><p>Hello world</p></div></li></ol>' ), | ||
str_replace( array( "\n", "\t" ), '', gutenberg_render_block_core_comment_template( null, null, $block ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real talk: Even though I wrote it, I don't know how I feel about this. autop
puts in some weird line breaks that I want to ignore but a line break is white space rather than an empty string.
I assume we should backport the fix to WP 6.0 beta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked like a charm!
@c4rl0sbr4v0 @peterwilsoncc @ockham @paaljoachim a corresponding PR against wordpress-develop will be needed to include these unit tests in WordPress 6.0. Is it something you want? If so, would you please create one? |
* Apply `comment_text` filter in comment template. * I think this is how I am supposed to test this. * Fix tests paragraphs break/I broke. * CS Fix. * Tidy assertions even more. * discard discardWhiteSpace — it was a bad idea. * Thinking face.
I cherry picked this change into |
@DAreRodz kindly took care of this: WordPress/wordpress-develop#2649 |
Awesome, I guess we will have merge those changes into WordPress/wordpress-develop#2651 to get green checks on CI 👍🏻 |
What?
Fixes #40248.
Apply
comment_text
filter in comment template to ensure paragraph breaks, smilies, links, etc are displayed.Why?
Ensure comments in a block theme are displayed with the original paragraph breaks included during authoring. Presently the content is shown as one blob which can become difficult to read.
How?
Traditional WP themes use
comment_template()
to echo the comment content.The final echo statement rules out it's use for rendering the template block but applying the same filter ensures parity in display between the comment loop and comment template.
Testing Instructions
trunk
will use the previously merged functions)trunk
Screenshots or screencast
Before
![Screen Shot 2022-04-28 at 12 13 00 pm](https://user-images.githubusercontent.com/519727/165663015-b5762a55-1e19-4bd0-b9ab-76ba6922a83c.png)
After
![Screen Shot 2022-04-28 at 12 13 29 pm](https://user-images.githubusercontent.com/519727/165663043-27a43821-cd56-489e-a5ff-c971aea6f37d.png)