Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/26/2025 07:26:02 PM (7 months ago)
Author:
espellcaste
Message:

Deprecate the current CSS class for the group item since it is too generic.

We also introduce a prefixed bp-group-status-{status} class (e.g., bp-group-status-hidden) while keeping the old non-prefixed class for backwards compatibility.

The old, non-prefixed, class will be properly removed in the next release (see #9316).

Props t.schwarz, dcavins, noruzzaman, and vapvarun.

Fixes #9308 (trunk)

File:
1 edited

Legend:

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

    r14077 r14173  
    671671         *
    672672         * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    673          *                                   Default: false.
     673         *                                                Default: false.
    674674         * @return int
    675675         */
     
    698698 * @since 1.7.0
    699699 *
    700  * @param array $classes Array of custom classes.
     700 * @param string[] $classes Array of custom classes.
    701701 */
    702702function bp_group_class( $classes = array() ) {
     
    711711         * @global BP_Groups_Template $groups_template The Groups template loop class.
    712712         *
    713          * @param array $classes Array of custom classes.
     713         * @param string[] $classes Array of custom classes.
    714714         * @return string Row class of the group.
    715715         */
     
    727727                }
    728728
    729                 // Group type - public, private, hidden.
    730                 $classes[] = sanitize_key( $groups_template->group->status );
     729                // Possible values include: public, private, hidden, etc.
     730                $group_status = sanitize_key( $groups_template->group->status );
     731                $classes[]    = 'bp-group-status-' . $group_status;
     732
     733                /**
     734                 * Will be removed in a future release.
     735                 *
     736                 * @deprecated Use the `bp-group-status-{status}` class instead.
     737                 *
     738                 * @see https://buddypress.trac.wordpress.org/ticket/9316
     739                 */
     740                $classes[] = $group_status;
    731741
    732742                // Add current group types.
    733                 if ( $group_types = bp_groups_get_group_type( bp_get_group_id(), false ) ) {
     743                $group_types = bp_groups_get_group_type( bp_get_group_id(), false );
     744                if ( is_array( $group_types ) ) {
    734745                        foreach ( $group_types as $group_type ) {
    735746                                $classes[] = sprintf( 'group-type-%s', esc_attr( $group_type ) );
     
    768779                 * @since 1.7.0
    769780                 *
    770                  * @param array $classes Array of determined classes for the row.
    771                  */
    772                 $classes = array_map( 'sanitize_html_class', apply_filters( 'bp_get_group_class', $classes ) );
     781                 * @param string[] $classes Array of determined classes for the row.
     782                 */
     783                $classes = apply_filters( 'bp_get_group_class', $classes );
     784
     785                $classes = array_map( 'sanitize_html_class', $classes );
    773786                $classes = array_merge( $classes, array() );
    774                 $retval = 'class="' . join( ' ', $classes ) . '"';
    775 
    776                 return $retval;
     787
     788                return 'class="' . join( ' ', $classes ) . '"';
    777789        }
    778790
Note: See TracChangeset for help on using the changeset viewer.