Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/03/2023 06:18:23 AM (3 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/core/nav/bpCoreNewSubnavItem.php

    r13449 r13468  
    349349    }
    350350
     351    public function screen_callback() {
     352        bp_core_load_template( 'members/single/plugins' );
     353    }
     354
     355    public function new_nav_hook() {
     356        bp_core_new_subnav_item(
     357            array(
     358                'name'            => 'Testing',
     359                'slug'            => 'testing',
     360                'parent_slug'     => bp_get_profile_slug(),
     361                'screen_function' => array( $this, 'screen_callback' ),
     362                'position'        => 20
     363            )
     364        );
     365    }
     366
    351367    /**
    352368     * @ticket BP7931
    353369     */
    354370    public function test_subnav_should_not_404_on_early_bp_setup_nav_priority() {
     371        // Register a subnav on 'bp_setup_nav' hook early (at priority zero).
     372        add_action( 'bp_setup_nav', array( $this, 'screen_callback' ), 0 );
     373
    355374        $u = self::factory()->user->create();
    356375        $old_current_user = get_current_user_id();
    357376        $this->set_current_user( $u );
    358377
    359         $user_domain = bp_members_get_user_url( $u );
    360 
    361         // Register a subnav on 'bp_setup_nav' hook early (at priority zero).
    362         add_action( 'bp_setup_nav', function() use ( $user_domain ) {
    363             /*
    364              * Emulate a subnav screen.
    365              *
    366              * The bp_core_load_template() call is imperative for our 404 check to work!
    367              */
    368             $screen = function() {
    369                 bp_core_load_template ('members/single/plugins');
    370             };
    371 
    372             // Register the subnav.
    373             bp_core_new_subnav_item( array (
    374                 'name'            => 'Testing',
    375                 'slug'            => 'testing',
    376                 'parent_url'      => $user_domain . bp_get_profile_slug (). '/',
    377                 'parent_slug'     => bp_get_profile_slug (),
    378                 'screen_function' => $screen,
    379                 'position'        => 20
    380             ) );
    381         }, 0 );
     378        $url = bp_members_get_user_url(
     379            $u,
     380            array(
     381                'single_item_component' => bp_get_profile_slug(),
     382                'single_item_action'    => 'testing',
     383            )
     384        );
    382385
    383386        // Emulate visit to our new subnav page.
    384         $this->go_to( $user_domain . bp_get_profile_slug () . '/testing/' );
     387        $this->go_to( $url );
    385388
    386389        // Assert that subnav page does not 404.
    387390        $this->assertFalse( is_404() );
    388391
     392        remove_action( 'bp_setup_nav', array( $this, 'screen_callback' ), 0 );
     393
    389394        $this->set_current_user( $old_current_user );
    390395    }
Note: See TracChangeset for help on using the changeset viewer.