Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/20/2011 11:58:01 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Add specific classes to body_class. Fixes #1478.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-general-template.php

    r2914 r2926  
    336336
    337337    return false;
     338}
     339
     340/**
     341 * Use the above is_() functions to output a body class for each scenario
     342 *
     343 * @param array $wp_classes
     344 * @param array $custom_classes
     345 *
     346 * @uses bbp_is_forum()
     347 * @uses bbp_is_topic()
     348 * @uses bbp_is_topic_edit()
     349 * @uses bbp_is_topic_merge()
     350 * @uses bbp_is_topic_split()
     351 * @uses bbp_is_reply()
     352 * @uses bbp_is_reply_edit()
     353 * @uses bbp_is_reply_edit()
     354 * @uses bbp_is_view()
     355 * @uses bbp_is_user_profile_edit()
     356 * @uses bbp_is_user_profile_page()
     357 * @uses bbp_is_user_home()
     358 * @uses bbp_is_subscriptions()
     359 * @uses bbp_is_favorites()
     360 * @uses bbp_is_topics_created()
     361 *
     362 * @return array
     363 */
     364function bbp_body_class( $wp_classes, $custom_classes = false ) {
     365
     366    $bbp_classes = array();
     367
     368    /** Components ********************************************************/
     369
     370    if ( bbp_is_forum() )
     371        $bbp_classes[] = bbp_get_forum_post_type();
     372
     373    if ( bbp_is_topic() )
     374        $bbp_classes[] = bbp_get_topic_post_type();
     375
     376    if ( bbp_is_topic_edit() )
     377        $bbp_classes[] = bbp_get_topic_post_type() . '-edit';
     378
     379    if ( bbp_is_topic_merge() )
     380        $bbp_classes[] = bbp_get_topic_post_type() . '-merege';
     381
     382    if ( bbp_is_topic_split() )
     383        $bbp_classes[] = bbp_get_topic_post_type() . '-split';
     384
     385    if ( bbp_is_reply() )
     386        $bbp_classes[] = bbp_get_reply_post_type();
     387
     388    if ( bbp_is_reply_edit() )
     389        $bbp_classes[] = bbp_get_reply_post_type() . '-edit';
     390
     391    if ( bbp_is_view() )
     392        $bbp_classes[] = 'bbp-view';
     393
     394    /** User **************************************************************/
     395
     396    if ( bbp_is_user_profile_edit() )
     397        $bbp_classes[] = 'bbp-user-edit';
     398
     399    if ( bbp_is_user_profile_page() )
     400        $bbp_classes[] = 'bbp-user-page';
     401
     402    if ( bbp_is_user_home() )
     403        $bbp_classes[] = 'bbp-user-home';
     404
     405    if ( bbp_is_topics_created() )
     406        $bbp_classes[] = 'bbp-topics-created';
     407
     408    if ( bbp_is_favorites() )
     409        $bbp_classes[] = 'bbp-favorites';
     410
     411    if ( bbp_is_subscriptions() )
     412        $bbp_classes[] = 'bbp-subscriptions';
     413
     414    /** Clean up **********************************************************/
     415
     416    // Add bbPress class if we are within a bbPress page
     417    if ( !empty( $bbp_classes ) )
     418        $bbp_classes[] = 'bbPress';
     419
     420    // Merge WP classes with bbPress classes
     421    $classes = array_merge( (array) $bbp_classes, (array) $wp_classes );
     422
     423    // Remove any duplicates
     424    $classes = array_unique( $classes );
     425
     426    return apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
    338427}
    339428
Note: See TracChangeset for help on using the changeset viewer.