Trying to figure out how to hide TinyMCE Controls (forcolor mainly) in WordPress 3.9 beta 2.
The code that was working in 3.8.1 was
$init['theme_advanced_disable'] = 'forecolor';
but theme_advanced_disable no longer seems to work. I can define the whole bar with
$init['toolbar1'] = '...';'
but all I really need to do is hide a few options. I feel like I’m just missing the new name… can anyone point me in the right direction?
2 Answers
I’m not sure if there is an official way to do this in TinyMCE 4.0 or not, I can’t find any references in their docs or on WordPress – below is a PHP method you could use to do this:
function myformatTinyMCE($in)
{
$del_buttons = array('bold', 'italic', 'strikethrough');
$temp = explode(',', $in['toolbar1']);
foreach($del_buttons as $del){
if(($key = array_search($del, $temp)) !== false){
unset($temp[$key]);
}
}
$temp = array_values($temp);
$in['toolbar1'] = implode(',', $temp);
return $in;
}
add_filter('tiny_mce_before_init', 'myformatTinyMCE', 10);
- Split Toolbar String into an Array
- Loop through our Delete array, if the value is in Temp, set the key
- Unset our button from our temp array
- Fix our values
- Convert it back to a string and set it back to Toolbar1