Make WordPress Core

Opened 7 years ago

Closed 2 years ago

#31947 closed enhancement (wontfix)

Allow developers to enable $br in wpautop() using a filter

Reported by: KTOmega Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: Formatting Keywords:
Focuses: Cc:


wpautop() can sometimes create unwanted <br/> tags in documents, where one is not needed or where a <p> is more appropriate. By adding the wpautop_br filter in wpautop, a theme developer can choose to force disable the $br argument:

apply_filters( 'wpautop_br', '__return_false' );

Attachments (1)

31947.diff (545 bytes) - added by KTOmega 7 years ago.
Adds wpautop_br filter in wpautop() in src/wp-includes/formatting.php.

Download all attachments as: .zip

Change History (3)

7 years ago

Adds wpautop_br filter in wpautop() in src/wp-includes/formatting.php.

#1 @bobbingwide
6 years ago

Hi, I support the requirement to disable br processing. My solution was to write a replacement filter function.

if ( !function_exists( "wpautop_nobr" ) ) {
function wpautop_nobr( $pee ) {
  return( wpautop( $pee, false ) );

Then remove the wpautop filter function and replace it with one with the same or different priority.

  remove_filter( 'the_content', 'wpautop' );
  add_filter( 'the_content', 'wpautop_nobr', 99 );

Would this satisfy your needs?

With regards to your patch.
If would be more efficient to defer the filter processing until after testing $pee.

#2 @pento
2 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Given that simple nature of the workaround that @bobbingwide posted, and that this hasn't been a popular requested filter, I'm going to close this issue.

Should we see situations that aren't covered by workarounds, we can always revisit this.

Note: See TracTickets for help on using tickets.