Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/22/2021 04:47:17 PM (3 years ago)
Author:
imath
Message:

Add a new method to the Members & Groups components main class

BP_Members_Component::setup_additional_globals() & BP_Groups_Component::setup_additional_globals() are used to set specific components globals that are not passed to BP_Component::setup_globals(). This commit also makes sure the BP Nouveau template pack uses a consistent object ID for its directory navigation.

Fixes #8555

File:
1 edited

Legend:

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

    r13021 r13087  
    153153            require $this->path . 'bp-members/screens/invitations.php';
    154154        }
     155    }
     156
     157    /**
     158     * Set up additional globals for the component.
     159     *
     160     * @since 10.0.0
     161     */
     162    public function setup_additional_globals() {
     163        $bp = buddypress();
     164
     165        /** Logged in user ***************************************************
     166         */
     167
     168        // The core userdata of the user who is currently logged in.
     169        $bp->loggedin_user->userdata = bp_core_get_core_userdata( bp_loggedin_user_id() );
     170
     171        // Fetch the full name for the logged in user.
     172        $bp->loggedin_user->fullname = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : '';
     173
     174        // Hits the DB on single WP installs so get this separately.
     175        $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
     176
     177        // The domain for the user currently logged in. eg: http://example.com/members/andy.
     178        $bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() );
     179
     180        /** Displayed user ***************************************************
     181         */
     182
     183        // The core userdata of the user who is currently being displayed.
     184        $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
     185
     186        // Fetch the full name displayed user.
     187        $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : '';
     188
     189        // The domain for the user currently being displayed.
     190        $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() );
     191
     192        // If A user is displayed, check if there is a front template
     193        if ( bp_get_displayed_user() ) {
     194            $bp->displayed_user->front_template = bp_displayed_user_get_front_template();
     195        }
     196
     197        /** Initialize the nav for the members component *********************
     198         */
     199
     200        $this->nav = new BP_Core_Nav();
     201
     202        /** Signup ***********************************************************
     203         */
     204
     205        $bp->signup = new stdClass;
     206
     207        /** Profiles Fallback ************************************************
     208         */
     209
     210        if ( ! bp_is_active( 'xprofile' ) ) {
     211            $bp->profile       = new stdClass;
     212            $bp->profile->slug = 'profile';
     213            $bp->profile->id   = 'profile';
     214        }
     215
     216        /** Network Invitations **************************************************
     217         */
     218
     219        $bp->members->invitations = new stdClass;
    155220    }
    156221
     
    213278        parent::setup_globals( $args );
    214279
    215         /** Logged in user ***************************************************
    216          */
    217 
    218         // The core userdata of the user who is currently logged in.
    219         $bp->loggedin_user->userdata       = bp_core_get_core_userdata( bp_loggedin_user_id() );
    220 
    221         // Fetch the full name for the logged in user.
    222         $bp->loggedin_user->fullname       = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : '';
    223 
    224         // Hits the DB on single WP installs so get this separately.
    225         $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
    226 
    227         // The domain for the user currently logged in. eg: http://example.com/members/andy.
    228         $bp->loggedin_user->domain         = bp_core_get_user_domain( bp_loggedin_user_id() );
    229 
    230         /** Displayed user ***************************************************
    231          */
    232 
    233         // The core userdata of the user who is currently being displayed.
    234         $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    235 
    236         // Fetch the full name displayed user.
    237         $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : '';
    238 
    239         // The domain for the user currently being displayed.
    240         $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
    241 
    242         // Initialize the nav for the members component.
    243         $this->nav = new BP_Core_Nav();
    244 
    245         // If A user is displayed, check if there is a front template
    246         if ( bp_get_displayed_user() ) {
    247             $bp->displayed_user->front_template = bp_displayed_user_get_front_template();
    248         }
    249 
    250         /** Signup ***********************************************************
    251          */
    252 
    253         $bp->signup = new stdClass;
    254 
    255         /** Profiles Fallback ************************************************
    256          */
    257 
    258         if ( ! bp_is_active( 'xprofile' ) ) {
    259             $bp->profile       = new stdClass;
    260             $bp->profile->slug = 'profile';
    261             $bp->profile->id   = 'profile';
    262         }
    263 
    264         /** Network Invitations **************************************************
    265          */
    266 
    267         $bp->members->invitations = new stdClass;
     280        // Additional globals.
     281        $this->setup_additional_globals();
    268282    }
    269283
Note: See TracChangeset for help on using the changeset viewer.