Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/18/2023 09:42:31 AM (18 months ago)
Author:
imath
Message:

BP Rewrites: start the migration process for the Groups component

  • Add rewrite tags & rules for the Groups directory type and the create URLs.
  • Introduce bp_get_group_url()/bp_group_url() & to retrieve/output a Groups single item URL using BP Rewrites.
  • Introduce bp_get_group_restricted_screens(), bp_get_group_extension_screens() & bp_get_group_screens() to get information about the Groups screens (in particular each screen rewrite ID). These functions will ease slug customizations from the BuddyPress URL settings tab.
  • Improve the Group creation process making sure it's using BP Rewrites to build URLs.
  • Perform easiest replacements for bp_get_group_permalink()/bp_group_permalink() & bp_get_groups_directory_permalink()/bp_groups_directory_permalink() in favor of bp_get_group_url()/bp_group_url() & bp_get_groups_directory_url()/bp_groups_directory_url()`.
  • Improve code formatting & properly escape single group URLs into templates.
  • Update impacted Unit Tests.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/75
See #4954

File:
1 edited

Legend:

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

    r13436 r13437  
    242242        $e = new $class_name();
    243243
    244         $this->go_to( bp_get_group_permalink( $g_obj ) );
     244        $this->go_to( bp_get_group_url( $g_obj ) );
    245245
    246246        $e->_register();
     
    266266        $e = new $class_name();
    267267
    268         $this->go_to( bp_get_group_permalink( $g_obj ) );
     268        $this->go_to( bp_get_group_url( $g_obj ) );
    269269
    270270        $e->_register();
     
    295295        // Test as non-logged-in user
    296296        $this->set_current_user( 0 );
    297         $this->go_to( bp_get_group_permalink( $g_obj ) );
     297        $this->go_to( bp_get_group_url( $g_obj ) );
    298298        $e->_register();
    299299        $this->assertFalse( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );
     
    306306        $this->set_current_user( $u );
    307307        $this->add_user_to_group( $u, $g );
    308         $this->go_to( bp_get_group_permalink( $g_obj ) );
     308        $this->go_to( bp_get_group_url( $g_obj ) );
    309309        $e->_register();
    310310        $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );
     
    340340        // Test as non-logged-in user
    341341        $this->set_current_user( 0 );
    342         $this->go_to( bp_get_group_permalink( $g_obj ) );
     342        $this->go_to( bp_get_group_url( $g_obj ) );
    343343        $e->_register();
    344344        $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );
     
    351351        $this->set_current_user( $u );
    352352        $this->add_user_to_group( $u, $g );
    353         $this->go_to( bp_get_group_permalink( $g_obj ) );
     353        $this->go_to( bp_get_group_url( $g_obj ) );
    354354        $e->_register();
    355355        $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );
     
    371371        ) );
    372372        $g_obj = groups_get_group( $g );
    373         $this->go_to( bp_get_group_permalink( $g_obj ) );
     373        $this->go_to( bp_get_group_url( $g_obj ) );
    374374
    375375        $this->set_current_user( 0 );
     
    398398        ) );
    399399        $g_obj = groups_get_group( $g );
    400         $this->go_to( bp_get_group_permalink( $g_obj ) );
     400        $this->go_to( bp_get_group_url( $g_obj ) );
    401401
    402402        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    441441        $this->set_current_user( $u );
    442442
    443         $this->go_to( bp_get_group_permalink( $g_obj ) );
     443        $this->go_to( bp_get_group_url( $g_obj ) );
    444444
    445445        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    486486        $this->add_user_to_group( $u, $g );
    487487
    488         $this->go_to( bp_get_group_permalink( $g_obj ) );
     488        $this->go_to( bp_get_group_url( $g_obj ) );
    489489
    490490        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    533533        $gm->promote( 'mod' );
    534534
    535         $this->go_to( bp_get_group_permalink( $g_obj ) );
     535        $this->go_to( bp_get_group_url( $g_obj ) );
    536536
    537537        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    580580        $gm->promote( 'admin' );
    581581
    582         $this->go_to( bp_get_group_permalink( $g_obj ) );
     582        $this->go_to( bp_get_group_url( $g_obj ) );
    583583
    584584        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    622622        $this->set_current_user( 0 );
    623623
    624         $this->go_to( bp_get_group_permalink( $g_obj ) );
     624        $this->go_to( bp_get_group_url( $g_obj ) );
    625625
    626626        $e1 = new BPTest_Group_Extension_Access_Anyone();
     
    664664        $this->set_current_user( 0 );
    665665
    666         $this->go_to( bp_get_group_permalink( $g_obj ) );
     666        $this->go_to( bp_get_group_url( $g_obj ) );
    667667
    668668        $e1 = new BPTest_Group_Extension_ShowTab_Anyone();
     
    707707        $this->set_current_user( $u );
    708708
    709         $this->go_to( bp_get_group_permalink( $g_obj ) );
     709        $this->go_to( bp_get_group_url( $g_obj ) );
    710710
    711711        $e1 = new BPTest_Group_Extension_ShowTab_Anyone();
     
    752752        $this->add_user_to_group( $u, $g );
    753753
    754         $this->go_to( bp_get_group_permalink( $g_obj ) );
     754        $this->go_to( bp_get_group_url( $g_obj ) );
    755755
    756756        $e1 = new BPTest_Group_Extension_ShowTab_Anyone();
     
    799799        $gm->promote( 'mod' );
    800800
    801         $this->go_to( bp_get_group_permalink( $g_obj ) );
     801        $this->go_to( bp_get_group_url( $g_obj ) );
    802802
    803803        $e1 = new BPTest_Group_Extension_ShowTab_Anyone();
     
    846846        $gm->promote( 'admin' );
    847847
    848         $this->go_to( bp_get_group_permalink( $g_obj ) );
     848        $this->go_to( bp_get_group_url( $g_obj ) );
    849849
    850850        $e1 = new BPTest_Group_Extension_ShowTab_Anyone();
     
    885885        $g_obj = groups_get_group( $g );
    886886
    887         $this->go_to( bp_get_group_permalink( $g_obj ) );
     887        $this->go_to( bp_get_group_url( $g_obj ) );
    888888
    889889        $e1 = new BPTest_Group_Extension_Widget_Method();
     
    907907        $g_obj = groups_get_group( $g );
    908908
    909         $this->go_to( trailingslashit( bp_get_group_permalink( $g_obj ) ) . 'members/' );
     909        $this->go_to(
     910            bp_get_group_url(
     911                $g_obj,
     912                array(
     913                    'single_item_component' => 'members',
     914                )
     915            )
     916        );
    910917
    911918        $e1 = new BPTest_Group_Extension_Widget_Method();
     
    939946        bp_register_group_extension( $f_class_name );
    940947
    941         $this->go_to( bp_get_group_permalink( $g_obj ) );
     948        $this->go_to( bp_get_group_url( $g_obj ) );
    942949        $nav = buddypress()->groups->nav->get_secondary( array(
    943950            'parent_slug' => $g_obj->slug ,
Note: See TracChangeset for help on using the changeset viewer.