bp_nouveau_get_loop_classes()
Get the component’s loop classes
Description
Return
(string) space separated value of classes.
Source
File: bp-templates/bp-nouveau/includes/template-tags.php
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | function bp_nouveau_get_loop_classes() { $bp_nouveau = bp_nouveau(); // @todo: this function could do with passing args so we can pass simple strings in or array of strings // The $component is faked if it's the single group member loop if ( ! bp_is_directory() && ( bp_is_group() && 'members' === bp_current_action() ) ) { $component = 'members_group' ; } elseif ( ! bp_is_directory() && ( bp_is_user() && ( 'my-friends' === bp_current_action() || 'mutual' === bp_current_action() ) ) ) { $component = 'members_friends' ; } else { $component = sanitize_key( bp_current_component() ); } $classes = array ( 'item-list' , sprintf( '%s-list' , str_replace ( '_' , '-' , $component ) ), 'bp-list' , ); if ( bp_is_user() && 'my-friends' === bp_current_action() ) { $classes [] = 'members-list' ; } if ( bp_is_user() && 'requests' === bp_current_action() ) { $classes [] = 'friends-request-list' ; } if ( bp_is_user() && 'mutual' === bp_current_action() ) { $classes [] = 'friends-mutual-list' ; } $available_components = array ( 'members' => true, 'groups' => true, 'blogs' => true, /* * Technically not a component but allows us to check the single group members loop as a seperate loop. */ 'members_group' => true, 'members_friends' => true, ); // Only the available components supports custom layouts. if ( ! empty ( $available_components [ $component ] ) && ( bp_is_directory() || bp_is_group() || bp_is_user() ) ) { $customizer_option = sprintf( '%s_layout' , $component ); $layout_prefs = bp_nouveau_get_temporary_setting( $customizer_option , bp_nouveau_get_appearance_settings( $customizer_option ) ); // check for layout options in browsers storage $list = false; if ( isset( $_POST [ 'extras' ] ) && ! empty ( $_POST [ 'extras' ][ 'layout' ] ) && 'list' == $_POST [ 'extras' ][ 'layout' ] ) { $list = true; } if ( $layout_prefs && (int) $layout_prefs > 1 ) { $grid_classes = bp_nouveau_customizer_grid_choices( 'classes' ); if ( isset( $grid_classes [ $layout_prefs ] ) && ! $list ) { $classes = array_merge ( $classes , array ( 'grid' , 'four' , /*Remove customizer number of columns in grid view*/ //$grid_classes[ $layout_prefs ],/*Remove customizer number of columns in grid view*/ ) ); } else { $classes = array_merge ( $classes , array ( 'four' , /*Remove customizer number of columns in grid view*/ //$grid_classes[ $layout_prefs ],/*Remove customizer number of columns in grid view*/ ) ); } if ( ! isset( $bp_nouveau ->{ $component } ) ) { $bp_nouveau ->{ $component } = new stdClass; } // Set the global for a later use. $bp_nouveau ->{ $component }->loop_layout = $layout_prefs ; } } /** * Filter to edit/add classes. * * NB: you can also directly add classes into the template parts. * * @since BuddyPress 3.0.0 * * @param array $classes The list of classes. * @param string $component The current component's loop. */ $class_list = ( array ) apply_filters( 'bp_nouveau_get_loop_classes' , $classes , $component ); return join( ' ' , array_map ( 'sanitize_html_class' , $class_list ) ); } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.