Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/03/2023 06:18:23 AM (4 years ago)
Author:
imath
Message:

Stop using BP Legacy URL parser in favor of the new BP Rewrites API

  • Deprecate bp_core_set_uri_globals(). This function is moved inside the BP Classic compatibility plugin.
  • Introduce the new bp_register_nav action to hook to when globalizing Members single item navigations from the BP_Component class.
  • Improve bp_get_component_navigations() so that Avatar/Cover images navigation items are moved inside the Profile sub nav if the Extended profile component is active.
  • Register Avatar/Cover images Ajax actions so that these actions trigger our new URL Parser inside Ajax context.
  • Improve the BP_Core_Nav::add_nav() method so that any BP action variable slugs can be customized.
  • Improve Members & Groups component canonical redirections.
  • Handle slugs customization persistency using directory pages post metas.
  • Introduce a new repair tool to reset all slugs to BuddyPress default one.
  • Adapt some PHPUnit tests to better handle our new URL parser.

Props Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/routing/groups.php

    r13449 r13468  
    5555        public function test_group_directory_with_type() {
    5656                $this->set_permalink_structure( '/%postname%/' );
    57                 bp_groups_register_group_type( 'foo' );
     57                bp_groups_register_group_type(
     58                        'foo',
     59                        array(
     60                                'has_directory' => true,
     61                        )
     62                );
     63
     64                $url = bp_get_groups_directory_url(
     65                        array(
     66                                'directory_type' => 'foo',
     67                        )
     68                );
     69
     70                $this->go_to( $url );
     71
     72                $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'foo', 0 ) );
     73        }
     74
     75        /**
     76         * @group group_types
     77         */
     78        public function test_group_directory_with_type_that_has_custom_directory_slug() {
     79                $this->set_permalink_structure( '/%postname%/' );
     80                bp_groups_register_group_type( 'bar', array( 'has_directory' => 'bars' ) );
     81
     82                $url = bp_get_groups_directory_url(
     83                        array(
     84                                'directory_type' => 'bars',
     85                        )
     86                );
     87
     88                $this->go_to( $url );
     89
     90                $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'bars', 0 ) );
     91        }
     92
     93        /**
     94         * @group group_types
     95         */
     96        public function test_group_directory_should_404_for_group_types_that_have_no_directory() {
     97                $this->set_permalink_structure( '/%postname%/' );
     98                bp_groups_register_group_type( 'taz', array( 'has_directory' => false ) );
     99
    58100                $this->go_to(
    59101                        bp_get_groups_directory_url(
    60102                                array(
    61                                         'directory_type' => 'foo',
    62                                 )
    63                         )
    64                 );
    65                 $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'foo', 0 ) );
    66         }
    67 
    68         /**
    69          * @group group_types
    70          */
    71         public function test_group_directory_with_type_that_has_custom_directory_slug() {
    72                 $this->set_permalink_structure( '/%postname%/' );
    73                 bp_groups_register_group_type( 'foo', array( 'has_directory' => 'foos' ) );
    74                 $this->go_to(
    75                         bp_get_groups_directory_url(
    76                                 array(
    77                                         'directory_type' => 'foos',
    78                                 )
    79                         )
    80                 );
    81                 $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'foos', 0 ) );
    82         }
    83 
    84         /**
    85          * @group group_types
    86          */
    87         public function test_group_directory_should_404_for_group_types_that_have_no_directory() {
    88                 $this->set_permalink_structure( '/%postname%/' );
    89                 bp_groups_register_group_type( 'taz', array( 'has_directory' => false ) );
    90                 $this->go_to(
    91                         bp_get_groups_directory_url(
    92                                 array(
    93103                                        'directory_type' => 'taz',
    94104                                )
    95105                        )
    96106                );
     107
    97108                $this->assertEmpty( bp_get_current_group_directory_type() );
    98109        }
    … …  
    167178        /**
    168179         * @group group_previous_slug
    169          * @group imath
    170180         */
    171181        public function test_group_previous_slug_most_recent_takes_precedence() {
Note: See TracChangeset for help on using the changeset viewer.