Skip to:
Content

BuddyPress.org

Changeset 9886


Ignore:
Timestamp:
05/21/2015 07:34:40 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Blogs: Updates to bp_get_blog_class()

  • Allow custom classes to be passed in via array parameter
  • Clean up comparisons and variable definitions

See #6384. See r9884, r9885.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-template.php

    r9819 r9886  
    713713 *
    714714 * @since BuddyPress (1.7.0)
    715  */
    716 function bp_blog_class() {
    717     echo bp_get_blog_class();
     715 *
     716 * @param array $classes Array of custom classes
     717 */
     718function bp_blog_class( $classes = array() ) {
     719    echo bp_get_blog_class( $classes );
    718720}
    719721    /**
     
    723725     *
    724726     * @global BP_Blogs_Template $blogs_template
     727     * @param array $classes Array of custom classes
    725728     *
    726729     * @return string Row class of the site.
    727730     */
    728     function bp_get_blog_class() {
     731    function bp_get_blog_class( $classes = array() ) {
    729732        global $blogs_template;
    730733
    731         $classes     = array();
    732         $pos_in_loop = (int) $blogs_template->current_blog;
    733 
    734         // If we've only one site in the loop, don't bother with odd and even.
    735         if ( $blogs_template->blog_count > 1 )
    736             $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
    737         else
     734        // Add even/odd classes, but only if there's more than 1 group
     735        if ( $blogs_template->blog_count > 1 ) {
     736            $pos_in_loop = (int) $blogs_template->current_blog;
     737            $classes[]   = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
     738
     739        // If we've only one site in the loop, don't bother with odd and even
     740        } else {
    738741            $classes[] = 'bp-single-blog';
     742        }
    739743
    740744        /**
     
    747751        $classes = apply_filters( 'bp_get_blog_class', $classes );
    748752        $classes = array_merge( $classes, array() );
    749 
    750         $retval = 'class="' . join( ' ', $classes ) . '"';
     753        $retval  = 'class="' . join( ' ', $classes ) . '"';
     754
    751755        return $retval;
    752756    }
Note: See TracChangeset for help on using the changeset viewer.