Changeset 8682 for trunk/src/bp-core/bp-core-template.php
- Timestamp:
- 07/23/2014 07:42:14 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r8677 r8682 2462 2462 2463 2463 /** 2464 * Customizes the post CSS class according to BuddyPress content. 2465 * 2466 * Hooked to the 'post_class' filter. 2467 * 2468 * @since BuddyPress (2.1.0) 2469 * 2470 * @param array $wp_classes The post classes coming from WordPress. 2471 * @return array 2472 */ 2473 function bp_get_the_post_class( $wp_classes = array() ) { 2474 // don't do anything if we're not on a BP page 2475 if ( ! is_buddypress() ) { 2476 return $wp_classes; 2477 } 2478 2479 $bp_classes = array(); 2480 2481 if ( bp_is_user() || bp_is_single_activity() ) { 2482 $bp_classes[] = 'bp_members'; 2483 2484 } elseif ( bp_is_group() ) { 2485 $bp_classes[] = 'bp_group'; 2486 2487 } elseif ( bp_is_activity_component() ) { 2488 $bp_classes[] = 'bp_activity'; 2489 2490 } elseif ( bp_is_blogs_component() ) { 2491 $bp_classes[] = 'bp_blogs'; 2492 2493 } elseif ( bp_is_register_page() ) { 2494 $bp_classes[] = 'bp_register'; 2495 2496 } elseif ( bp_is_activation_page() ) { 2497 $bp_classes[] = 'bp_activate'; 2498 2499 } elseif ( bp_is_forums_component() && bp_is_directory() ) { 2500 $bp_classes[] = 'bp_forum'; 2501 } 2502 2503 if ( empty( $bp_classes ) ) { 2504 return $wp_classes; 2505 } 2506 2507 // emulate post type css class 2508 foreach ( $bp_classes as $bp_class ) { 2509 $bp_classes[] = "type-{$bp_class}"; 2510 } 2511 2512 // removes the 'page' and 'type-page' post classes 2513 // we need to remove these classes since they did not exist before we switched 2514 // theme compat to use the 'page' post type 2515 $page_key = array_search( 'page', $wp_classes ); 2516 $page_type_key = array_search( 'type-page', $wp_classes ); 2517 unset( $wp_classes[$page_key], $wp_classes[$page_type_key] ); 2518 2519 // okay let's merge! 2520 return array_unique( array_merge( $bp_classes, $wp_classes ) ); 2521 } 2522 add_filter( 'post_class', 'bp_get_the_post_class' ); 2523 2524 /** 2464 2525 * Sort BuddyPress nav menu items by their position property. 2465 2526 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)