Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change TinyMCE to not add paragraphs


  • blasterspike
    Participant

    @blasterspike

    Hi,
    I have followed this documentation page

    Enable Visual Editor


    to enable TinyMCE. Now I would like to change the default behavior of TinyMCE to not add a paragraph for each new line but use instead <br>.
    For WordPress I have to use this

    function tinymce_remove_root_block_tag( $init ) {
        $init['forced_root_block'] = false; 
        return $init;
    }
    add_filter( 'tiny_mce_before_init', 'tinymce_remove_root_block_tag' );

    But the TinyMCE in bbPress doesn’t get this setting.
    I have tried to do something like

    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['quicktags'] = false;
        $args['forced_root_block'] = false;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    but it doesn’t work.
    How can I pass that “forced_root_block” to the TinyMCE enabled for bbPress?

    Thanks

    Massimo

Viewing 3 replies - 1 through 3 (of 3 total)

  • Robin W
    Moderator

    @robin-w

    not my field of expertise, but suggest you have the wp code,

    and try

    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['quicktags'] = false;
        return $args;
    }
    add_filter( 'bbp_before_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    this just does the ‘turn on’ earlier

    may work, may not !!


    blasterspike
    Participant

    @blasterspike

    Hi Robin,
    thank you for your reply.
    I have tried with

    function tinymce_remove_root_block_tag( $init ) {
        $init['forced_root_block'] = false; 
        return $init;
    }
    add_filter( 'tiny_mce_before_init', 'tinymce_remove_root_block_tag' );
    
    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['quicktags'] = false;
        return $args;
    }
    add_filter( 'bbp_before_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    or with

    function tinymce_remove_root_block_tag( $init ) {
        $init['forced_root_block'] = false; 
        return $init;
    }
    add_filter( 'tiny_mce_before_init', 'tinymce_remove_root_block_tag' );
    
    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['quicktags'] = false;
        $args['forced_root_block'] = false;
        return $args;
    }
    add_filter( 'bbp_before_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    but I’m still getting a new paragraph for each new line.


    Robin W
    Moderator

    @robin-w

    hmmm… as I say beyond my area of knowledge but was worth a punt.

    If you do fix, please do post the solution here as it will help others in future.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar