Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: TinyMCE buttons – how to filter?

@hansaplastique

Participant

Thanks Stephen – and here I thought the “code” button would do that for me 😉
I’ll paste the code again, as you can see I removed some buttons (that have no purpose anyway) and added some …


add_filter('tiny_mce_before_init', 'tinymce_other_css_for_content');

function bbp_mce_override( $args = array() ) {
$args['teeny'] = false;
return $args;
}
add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_mce_override' );

if (!is_super_admin()) // remove/add buttons for non admins
{
function add_tinymce_buttons($buttons)
{
$arr_size=count($buttons);
$remove_these=array('blockquote','wp_adv','fullscreen','wp_more');

for ($counter=$arr_size; $counter>=0; $counter--)
{
if ( in_array($buttons[$counter],$remove_these) )
{
unset($buttons[$counter]);
}
}

array_push($buttons,'separator','cut','copy','paste','separator','undo','redo','separator','sub','sup','forecolor','backcolor','charmap');

return $buttons;
}

function add_tinymce_buttons_2($buttons)
{
unset($buttons);
return $buttons;
}

add_filter('mce_buttons', 'add_tinymce_buttons');
add_filter('mce_buttons_2', 'add_tinymce_buttons_2');
}

For some of these to work I had to expand the allowed_tags in WordPress (be carefull when doing this) using the following code;


function my_allowed_html_tags_in_comments() {
define('CUSTOM_TAGS', true);
global $allowedtags;

$allowedtags = array(
'a' => array(
'href' => array (),
'title' => array ()),
'blockquote' => array(
'cite' => array ()),
'cite' => array (),
'code' => array(),
'em' => array(),
'strong' => array(),
'pre' => array(
'class' => array()),
'p' => array(
'style' => array()),
'span' => array(
'style' => array()),
'sup' => array(),
'sub' => array()
);
}

add_action('init', 'my_allowed_html_tags_in_comments', 10);

Hope it’s helpful to someone 🙂

Skip to toolbar