Skip to:
Content

BuddyPress.org

Changeset 6382


Ignore:
Timestamp:
10/03/2012 06:57:37 PM (12 years ago)
Author:
djpaul
Message:

Add first pass at new bp_blog_class() template function to generate row class styles for the sites directory template parts. See #3741

File:
1 edited

Legend:

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

    r6380 r6382  
    358358
    359359        return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
     360    }
     361
     362
     363/**
     364 * Output the row class of a site
     365 *
     366 * @since BuddyPress (1.7)
     367 */
     368function bp_blog_class() {
     369    echo bp_get_blog_class();
     370}
     371    /**
     372     * Return the row class of a site
     373     *
     374     * @global BP_Blogs_Template $blogs_template
     375     * @return string Row class of the site
     376     * @since BuddyPress (1.7)
     377     */
     378    function bp_get_blog_class() {
     379        global $blogs_template;
     380
     381        $classes     = array();
     382        $pos_in_loop = (int) $blogs_template->current_blog;
     383
     384        // If we've only one site in the loop, don't bother with odd and even.
     385        if ( $blogs_template->blog_count > 1 )
     386            $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
     387        else
     388            $classes[] = 'bp-single-blog';
     389
     390        $classes = apply_filters( 'bp_get_blog_class', $classes );
     391        $classes = array_merge( $classes, array() );
     392
     393        $retval = 'class="' . join( ' ', $classes ) . '"';
     394        return $retval;
    360395    }
    361396
Note: See TracChangeset for help on using the changeset viewer.