bbPress: Allow Headings and Code Blocks in Posts
Lets forum members use more formatting in topics and replies, such as headings, preformatted code blocks and tables, which is handy for technical forums.
Opens WPIDE on
Code
if ( ! function_exists( 'bbp_kses_allowed_tags' ) ) {
return;
}
add_filter( 'bbp_kses_allowed_tags', function ( $tags ) {
foreach ( array( 'h3', 'h4', 'pre', 'table', 'thead', 'tbody', 'tr', 'td', 'th', 'kbd', 'hr' ) as $tag ) {
if ( ! isset( $tags[ $tag ] ) ) {
$tags[ $tag ] = array();
}
}
$tags['code'] = array( 'class' => true );
return $tags;
} );
Notes
Only harmless formatting tags are added; no scripts, styles or attributes that could be abused.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.