• Resolved codejp3

    (@codejp3)


    Quick Question:

    How do I disable the TinyMCE addition for Code Snippets. I do not want it to be displayed in the TinyMCE toolbar.

    I recently setup a BBPress forum and went with a more advanced TinyMCE editor on the front end and do not want the Code Snippets button/dropdown included within the forum.

    I’d prefer to disable it only on the front-end of the site, but I’m fine disabling it site-wide as well since I never seem to use it.

    Can’t find any settings to disable it.

    If need be, I’ll look through your code and see where you’re hooking into and deregister your hook, but thought I’d ask first.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter codejp3

    (@codejp3)

    Well, answered my own question.

    Made this little snippet, and even kept BBPress context so it’s only disabled in the front end forum.

    
    add_filter( 'mce_buttons', 'codejp3_remove_code_snippets_button', 99 );
    function codejp3_remove_code_snippets_button( $buttons ) {
    	if ( is_bbpress() ) {
    		$buttons = array_diff($buttons, ["code_snippets"]);
    		return $buttons;
    	}
    }
    

    I think adding a setting for this within the plugin is overkill, especially if you factor in context (like only on BBPress)…. BUT perhaps something like this should be a default sample snippet that ships with Code Snippets? Something like:

    
    add_filter( 'mce_buttons', function ( $buttons ) {
    	$buttons = array_diff($buttons, ["code_snippets"]);
    	return $buttons;
    });
    
    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @codejp3,

    You can remove it with the mce_buttons filter:

    add_filter( 'mce_buttons', function ( $buttons ) {
        return is_admin() ? 
            $buttons :
            array_diff( $buttons, array( 'code_snippets' ) );
    }, 15 );
    Plugin Author Shea Bunge

    (@bungeshea)

    Ah, my apologies, I didn’t see your follow-up post earlier.

    I have added it as a snippet on our cloud platform, which will soon be replacing the sample snippets included with the plugin: https://codesnippets.cloud/snippet/shea/remove-snippets-tinymce-button

    Thread Starter codejp3

    (@codejp3)

    Thanks for the reply and link to the codesnippets cloud!

    Between our posts, there’s 3 variations of disabling the TinyMCE buttons:

    1. Only in bbPress
    2. Site-wide
    3. Only in admin panel

    I could think of plenty more conditions to enable/disable it as well. No way to cover every scenario and justifies NEVER making it a built-in dedicated plugin setting and keeping it an optional code snippet.

    Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable the TinyMCE Code Snippets Button/Dropdown’ is closed to new replies.