BP Theme Authors: make sure your theme registers 'buddypress' support

The theme compatibility layer coming in BuddyPress 1.7 makes it so that any WordPress theme is BP-compatible. If you are an author of an existing theme that supplies its own BuddyPress templates, you can (and should) prevent BuddyPress from running theme compat in the context of your theme. You can do so by putting the following line in your functions.php:


add_theme_support( 'buddypress' );

Be sure that you put this line either in the global scope, or in a function that is hooked to 'after_setup_theme' with a priority of less than 100. See http://codex.wordpress.org/Function_Reference/add_theme_support and http://buddypress.trac.wordpress.org/ticket/4846#comment:4 for more information.

Here’s an explanation of why this change is necessary. In order to maintain full backward-compatibility with existing BP themes, theme compat only kicks in as a fallback. On any given page, BP first checks to see whether it can find the “old” templates in your theme directory (such as groups/single/members.php); if the old template is found, it is used, while if it’s not found, BP supplies the markup using theme compat. This means that, in the case of PHP templates, your legacy BP theme will work seamlessly with BP 1.7+.

In the case of CSS and JS, however, BP has no reliable way to know whether a theme is providing the necessary files to make your site look and work correctly. Theme compat errs on the side of caution and loads these static assets. But if your theme has also loaded its own version of these files, it may create conflicts in styling, and more importantly, it may cause certain AJAX events to be fired twice. add_theme_support( 'buddypress' ) tells BP that your theme will be taking care of CSS and JS (in addition to PHP templates).

Note that child themes of bp-default do not need to manually register ‘buddypress’ support; BP assumes it.

See #4846 for more details.