Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/23/2021 02:27:58 PM (2 years ago)
Author:
dcavins
Message:

Improve behavior of bp_init_group_extensions().

In r13101, the behavior of bp_register_group_extension()
was changed to make it possible to modify the behavior via
plugins. However, the same code in a new place behaved
differently, only fully registering the last group extension that
was passed to it. This commit stops passing the group
extension classes by reference, which fixes the issue.

See #8558.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php

    r11737 r13195  
    888888        $this->assertFalse( $content === 'Widget Displayed' );
    889889    }
     890
     891    /**
     892     * @ticket BP8558
     893     */
     894    public function test_adding_multiple_extension_classes() {
     895        $old_options_nav = buddypress()->bp_options_nav;
     896
     897        $g = self::factory()->group->create();
     898        $g_obj = groups_get_group( $g );
     899
     900        $e = new BPTest_Group_Extension_Enable_Nav_Item_True();
     901        $e_slug = 'bptest_group_extension_enable_nav_item_true';
     902        $e_class_name = get_class( $e );
     903        $f = new BPTest_Group_Extension_Access_Anyone();
     904        $f_slug = 'bptest_group_extension_access_anyone';
     905        $f_class_name = get_class( $f );
     906
     907        bp_register_group_extension( $e_class_name );
     908        bp_register_group_extension( $f_class_name );
     909
     910        $this->go_to( bp_get_group_permalink( $g_obj ) );
     911        $nav = buddypress()->groups->nav->get_secondary( array(
     912            'parent_slug' => $g_obj->slug ,
     913        ) );
     914
     915        $slugs = array();
     916        foreach ( $nav as $priority => $nav_obj ) {
     917            $slugs[] = $nav_obj->slug;
     918        }
     919
     920        $this->assertTrue( in_array( $e_slug, $slugs, true ) && in_array( $f_slug, $slugs, true ) );
     921
     922        // Clean up
     923        buddypress()->bp_options_nav = $old_options_nav;
     924    }
    890925}
Note: See TracChangeset for help on using the changeset viewer.