TinyMCE in Buddypress

I threw a little something together today to add WYSIWYG editing to BuddyPress, using TinyMCE. I want to be careful about the tags I allow, so I’m whitelisting, which is a bit tedious. As a result, there are only a few buttons available: a, em, strong, ul, ol, li. It’s a start, though.

Seems to work everywhere in BP: forums, wire, messages, profile pages.

A note about TinyMCE: WP ships with TinyMCE, and I thought it made sense to use that version instead of attaching one to this plugin. I think that the path to TinyMCE (line 20 of the plugin) should work on all installations, but you may have to tinker if you don’t see it popping up in the head of your BP pages. Moreover, the language files for WP’s version of TinyMCE are misnamed, which means that they don’t work right out of the box (at least for me they don’t). You may need to change the name of wp-includes/js/tinymce/langs/wp-langs-en.php to en.php in order to get the hover and help text in the TinyMCE box to work.

Download the plugin here. Don’t use in a production environment unless you are very certain that you are satisfied with the security of this plugin!

TinyMCE in Buddypress by Boone Gorges, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

54 thoughts on “TinyMCE in Buddypress

  1. AntonRSA

    I’m using bp 1.1.3

    Should I still add the filter

    add_filter( ‘bp_get_activity_parent_content’, ‘bp_tinymce_allowed_tags’, 2 );

  2. AntonRSA

    lol – panic, panic, panic

    I tried to deactivate the plugin but it seems that everywhere where forum topics were made using the editor, the html tags now show.

    If I deactivate the plugin – is there anyway that I can configure it so that the forum posts doesn’t display html tags   anymore or is this a manual thing?

  3. Boone Gorges Post author

    Anton – At some point, did you turn off some of the default filters? Look in bp-activity/bp-activity-filters.php, bp-forums/bp-forums-filters.php, etc and see if you commented anything out. In each of those files there should be a line that hooks wp_filter_kses to something along the lines of bp_get_the_activity_content. I’m pretty sure it’s that filter that removes HTML tags. You might compare those files to fresh versions downloaded from wordpress.org/plugins.

    Worst case scenario: You can hook the function wp_filter_nohtml_kses to any of the get events, eg add_filter( 'bp_get_the_activity_content', 'wp_filter_nohtml_kses', 10, 1 );. You definitely should not have to go through and remove HTML tags one by one!

  4. Dan Butcher

    Boone, after I disabled your plugin, I tried MCEcomment (Visit plugin site), which adds TinyMCE to comments only; it didn’t work at all (and had worked previously). So, I’m thinking that there’s some other plugin I’ve added that’s conflicting with both of these. I’m going to try BP TinyMCE on a clean install with no other plugins to see what happens and let you know.

Comments are closed.