WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 10 months ago

#23135 closed enhancement (duplicate)

Filter for Block Elements in wpautop()

Reported by: luehrsen Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Formatting Keywords: has-patch 2nd-opinion wpautop
Focuses: Cc:

Description

This addresses the need to exclude certain block elements (iframe, img) from wpautop. Using the newly defined filter wpautop_block_elements every plugin dev, theme dev etc. can redefine, modify and enhance the list of block elements.

Exsample for functions.php

function add_block_elements($block_elements){   
        $block_elements[] = "iframe";   
        $block_elements[] = "img";      
        
        return $block_elements;
}
add_filter("wpautop_block_elements", add_block_elements);

Thanks for reviewing! :)

Regards,
Hendrik

Attachments (1)

formats.diff (1.4 KB) - added by luehrsen 2 years ago.
Defined preexisting block elements as array, filtered that array, imploded to regex.

Download all attachments as: .zip

Change History (6)

@luehrsen2 years ago

Defined preexisting block elements as array, filtered that array, imploded to regex.

comment:1 @nacin2 years ago

Neither iframes nor images are block-level elements. This mangling should not be left to plugins.

comment:2 @luehrsen2 years ago

As for HTML standards, HTML5 does not any longer differentiate between inline and block, it rather has more categories possible for each element. http://dev.w3.org/html5/html4-differences/#content-model

Aside from digging into standards, there should be a standardized way for developers to exclude certain elements from wpautop. Disabling and optionally replacing the function (as it is regularly done) is not a suitable solution.

comment:3 @SergeyBiryukov2 years ago

  • Version changed from trunk to 3.5

comment:4 @nacin16 months ago

  • Keywords wpautop added

comment:5 @wonderboymusic10 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Newer discussion/patch on #28607.

Note: See TracTickets for help on using tickets.