Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/16/2023 03:43:26 PM (20 months ago)
Author:
imath
Message:

Make sure bp_core_new_nav_default() is ready for the BP Rewrites API

  • In case plain permalinks are used, use the $GLOBALS['wp']->query_string to set the buddypress()->unfiltered_uri global.
  • Do not edit sub nav links when calling bp_core_new_nav_default() if the URL parser is set to 'rewrites'.
  • Avoid a PHP notice if the new sub nav object misses the slug and/or the link properties.

Props corzel

See #4954
Fixes #8936
Closes https://github.com/buddypress/buddypress/pull/130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template-loader.php

    r13492 r13519  
    570570
    571571    if ( ! $bp->unfiltered_uri ) {
    572         $bp->unfiltered_uri        = explode( '/', $GLOBALS['wp']->request );
     572        $unfiltered_uri = explode( '/', $GLOBALS['wp']->request );
     573
     574        // Make sure to set the BP unfiltered_uri global when plain links are used.
     575        if ( ! bp_has_pretty_urls() ) {
     576            $bp_directories = array();
     577            foreach ( $bp->pages as $component_id => $page_properties ) {
     578                if ( isset( $bp->{$component_id}->rewrite_ids['directory'] ) ) {
     579                    $bp_directories[ $bp->{$component_id}->rewrite_ids['directory'] ] = $page_properties->slug;
     580                } elseif ( 'activate' === $component_id || 'register' === $component_id ) {
     581                    $bp_directories[ 'bp_member_' . $component_id ] = $page_properties->slug;
     582                }
     583            }
     584
     585            $url_query_chunks = bp_parse_args( $GLOBALS['wp']->query_string, array() );
     586            $directory        = key( $url_query_chunks );
     587            if ( isset( $bp_directories[ $directory ] ) ) {
     588                $url_query_chunks[ $directory ] = $bp_directories[ $directory ];
     589            }
     590
     591            $unfiltered_uri = array_values( $url_query_chunks );
     592        }
     593
     594        $bp->unfiltered_uri        = $unfiltered_uri;
    573595        $bp->unfiltered_uri_offset = 0;
    574596    }
Note: See TracChangeset for help on using the changeset viewer.