Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (18 months ago)
Author:
imath
Message:

Make BP_Core_Nav generate "BP Rewrites ready" navigation links

  • Remove all components $parent_url attributes when setting sub nav items.
  • Only use the bp_core_create_nav_link() $link attribute argument & the bp_core_create_subnav_link() $parent_url attribute argument if specified to preserve backward compatibility.
  • Migrates the Community search feature so that it uses BP Rewrites.
  • Perform some bp_loggedin_user_domain() in favor of bp_loggedin_user_url().
  • Update some PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-core.php

    r13432 r13441  
    292292        // Is the logged in user is a mod for the current item?
    293293        bp_update_is_item_mod( false, 'core' );
     294
     295        /*
     296         * As the BP Core component is excluded from the BP Component code
     297         * used to set the Rewrite IDs, we need to set it here. As the `search`
     298         * word is already a WordPress rewrite tag, we are not adding a custom
     299         * rule for this component to avoid messing with it.
     300         */
     301        $this->rewrite_ids = array(
     302            'community_search' => 'bp_search',
     303        );
    294304
    295305        parent::setup_globals(
     
    401411
    402412        parent::register_post_statuses();
     413    }
     414
     415    /**
     416     * Parse the WP_Query and eventually set the BP Search mechanism.
     417     *
     418     * Search doesn't have an associated page, so we check for it separately.
     419     *
     420     * @since 12.0.0
     421     *
     422     * @param WP_Query $query Required. See BP_Component::parse_query() for
     423     *                        description.
     424     */
     425    public function parse_query( $query ) {
     426        $is_search = $query->get( 'pagename' ) === bp_get_search_slug() || ( isset( $_GET['bp_search'] ) && 1 === (int) $_GET['bp_search'] );
     427
     428        if ( isset( $_POST['search-terms'] ) && $is_search ) {
     429            buddypress()->current_component = bp_get_search_slug();
     430        }
     431
     432        parent::parse_query( $query );
    403433    }
    404434
Note: See TracChangeset for help on using the changeset viewer.