Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add ‘code’ button to teeny_mce visual editor

  • @johnmontfx

    Participant

    I’m using the following php to attempt to add a ‘code’ formatting button to the teeny mce editor (I’d like to keep it teeny if possible):

    function fx_teeny_mce_buttons( $buttons, $editor_id ) {
    	$buttons[] = 'code';
    	return $buttons;
    }
    add_filter( 'bbp_get_teeny_mce_buttons', 'fx_teeny_mce_buttons');

    However, the button isn’t showing. It does, however, appear in the $buttons array.

    Any suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @casiepa

    Moderator

    I suppose that
    add_filter( 'bbp_get_teeny_mce_buttons',
    should be
    add_filter( 'bbp_get_teeny_mce_plugins',

    Check out https://codex.bbpress.org/enable-visual-editor/

    Pascal.

    @johnmontfx

    Participant

    Thank you for the response. I tried that as well, since I’m adding the “paste” plugin with the following code (with an array print for debugging):

    add_filter( 'bbp_get_tiny_mce_plugins', 'fx_tinymce_paste_plain_text' );
    
    function fx_tinymce_paste_plain_text( $plugins = array() ) {
        $plugins[] = 'paste';
        $plugins[] = 'code';
        print_r($plugins);
        return $plugins;
    }

    But what I get is the following — no buttons. (you can see the $plugins array contents):

    If I remove the “$plugins[] = code;” line — I get the buttons back:

    paste only

    I’m not seeing any errors in php.log — so I must be doing something wrong. I’m curious if it is because a code button can’t be there without the dropdown menu. Or maybe I need to show the quicktags part of the visual editor

    @casiepa

    Moderator

    hmmm, can you try

    function fx_tinymce_paste_plain_text( $plugins = array() ) {
        array_push($plugins,"paste","code");
        print_r($plugins);
        return $plugins;
    }

    Pascal.

    @casiepa

    Moderator

    ha, now I see the print_r at the bottom… seems to be correct anyway !!
    I must be missing something, but I don’t see what

    EDIT: colorpicker, lists, … ??? Can you change $plugins with $buttons ?

    @johnmontfx

    Participant

    I’ve also set it up so adding a button AND plugin for “code” are hooked in, but still no luck.

    Good idea to try some other plugins/buttons to try and debug this…

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