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;
});
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 );
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
Thanks for the reply and link to the codesnippets cloud!
Between our posts, there’s 3 variations of disabling the TinyMCE buttons:
- Only in bbPress
- Site-wide
- 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!