Skip to:
Content

BuddyPress.org

Ticket #3842: 3842-concept.diff

File 3842-concept.diff, 1.6 KB (added by dcavins, 3 years ago)

An example change.

  • src/bp-groups/bp-groups-functions.php

    diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
    index 006bf6f..bde6b9c 100644
    function groups_total_groups_for_user( $user_id = 0 ) { 
    957957 * @return BP_Groups_Group The current group object.
    958958 */
    959959function groups_get_current_group() {
     960        global $groups_template;
    960961        $bp = buddypress();
     962        $current_group = false;
    961963
    962         $current_group = isset( $bp->groups->current_group )
    963                 ? $bp->groups->current_group
    964                 : false;
     964        // Check the template first, in case we're in a groups loop inside of a group.
     965        if ( ! empty( $groups_template->group ) && ( $groups_template->group instanceof BP_Groups_Group) ) {
     966                $current_group = $groups_template->group;
     967        // Next we check the bp global.
     968        } elseif ( ! empty( $bp->groups->current_group ) && ( $bp->groups->current_group instanceof BP_Groups_Group ) ) {
     969                $current_group = $bp->groups->current_group;
     970        }
    965971
    966972        /**
    967973         * Filters the BP_Groups_Group object corresponding to the current group.
  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index 2e467a4..0b5ba0d 100644
    function bp_group_name( $group = false ) { 
    643643         * @return string
    644644         */
    645645        function bp_get_group_name( $group = false ) {
    646                 global $groups_template;
    647646
    648                 if ( empty( $group ) ) {
    649                         $group =& $groups_template->group;
     647                if ( ! ( $group instanceof BP_Groups_Group ) ) {
     648                        $group = groups_get_current_group();
    650649                }
    651650
    652651                /**