Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/18/2023 02:20:59 AM (3 years ago)
Author:
imath
Message:

Improve BP_Members_Component::check_parsed_query()

As some sub nav items can be added to an existing component by third party plugin authors, checking for an existing and valid screen function from the component's sub_nav property is not enough. We also need to do the same check using The Member's component secondary navigation object.

Fixes #8996
Closes https://github.com/buddypress/buddypress/pull/166

File:
1 edited

Legend:

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

    r13534 r13583  
    992992
    993993                        $bp = buddypress();
    994                         if ( isset( $bp->{$single_item_component}, $bp->{$single_item_component}->sub_nav ) ) {
    995                                 $screen_functions = wp_list_pluck( $bp->{$single_item_component}->sub_nav, 'screen_function', 'slug' );
    996 
    997                                 if ( ! $single_item_action || ! isset( $screen_functions[ $single_item_action ] ) || ! is_callable( $screen_functions[ $single_item_action ] ) ) {
     994                        if ( isset( $bp->{$single_item_component} ) ) {
     995                                $screen_function = '';
     996
     997                                if ( isset( $bp->{$single_item_component}->sub_nav ) ) {
     998                                        $screen_functions = wp_list_pluck( $bp->{$single_item_component}->sub_nav, 'screen_function', 'slug' );
     999
     1000                                        if ( isset( $screen_functions[ $single_item_action ] ) ) {
     1001                                                $screen_function = $screen_functions[ $single_item_action ];
     1002                                        }
     1003                                }
     1004
     1005                                // Check if this nav item has been added from outside the Component's class.
     1006                                if ( ! $screen_function ) {
     1007                                        $sub_nav = $this->nav->get( $single_item_component . '/' . $single_item_action );
     1008
     1009                                        if ( isset( $sub_nav->screen_function ) && $sub_nav->screen_function ) {
     1010                                                $screen_function = $sub_nav->screen_function;
     1011                                        }
     1012                                }
     1013
     1014                                if ( ! $single_item_action || ! $screen_function || ! is_callable( $screen_function ) ) {
    9981015                                        bp_do_404();
    9991016                                        return;
Note: See TracChangeset for help on using the changeset viewer.