BP_Core::setup_globals( array $args = array() )

Set up bp-core global settings.

Description

Sets up a majority of the BuddyPress globals that require a minimal amount of processing, meaning they cannot be set in the BuddyPress class.

See also

Parameters

$args

(Optional) See BP_Component::setup_globals().

Default value: array()

Source

File: bp-core/classes/class-bp-core.php

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
public function setup_globals($args = array()) {
    $bp = buddypress();
 
    /** Database *********************************************************
     */
 
    // Get the base database prefix.
    if (empty($bp->table_prefix)) {
        $bp->table_prefix = bp_core_get_table_prefix();
    }
 
    // The domain for the root of the site where the main blog resides.
    if (empty($bp->root_domain)) {
        $bp->root_domain = bp_core_get_root_domain();
    }
 
    // Fetches all of the core BuddyPress settings in one fell swoop.
    if (empty($bp->site_options)) {
        $bp->site_options = bp_core_get_root_options();
    }
 
    // The names of the core WordPress pages used to display BuddyPress content.
    if (empty($bp->pages)) {
        $bp->pages = bp_core_get_directory_pages();
    }
 
    /** Basic current user data ******************************************
     */
 
    // Logged in user is the 'current_user'.
    $current_user = wp_get_current_user();
 
    // The user ID of the user who is currently logged in.
    $bp->loggedin_user = new stdClass;
    $bp->loggedin_user->id = isset($current_user->ID) ? $current_user->ID : 0;
 
    /** Avatars **********************************************************
     */
 
    // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar.
    $bp->grav_default = new stdClass;
 
    /**
     * Filters the default user Gravatar.
     *
     * @since BuddyPress 1.1.0
     *
     * @param string $value Default user Gravatar.
     */
    $bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
 
    /**
     * Filters the default group Gravatar.
     *
     * @since BuddyPress 1.1.0
     *
     * @param string $value Default group Gravatar.
     */
    $bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
 
    /**
     * Filters the default blog Gravatar.
     *
     * @since BuddyPress 1.1.0
     *
     * @param string $value Default blog Gravatar.
     */
    $bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
 
    // Notifications table. Included here for legacy purposes. Use
    // bp-notifications instead.
    $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
 
    // Backward compatibility for plugins modifying the legacy bp_nav and bp_options_nav global properties.
    $bp->bp_nav = new BP_Core_BP_Nav_BackCompat();
    $bp->bp_options_nav = new BP_Core_BP_Options_Nav_BackCompat();
 
    /**
     * Used to determine if user has admin rights on current content. If the
     * logged in user is viewing their own profile and wants to delete
     * something, is_item_admin is used. This is a generic variable so it
     * can be used by other components. It can also be modified, so when
     * viewing a group 'is_item_admin' would be 'true' if they are a group
     * admin, and 'false' if they are not.
     */
    bp_update_is_item_admin(bp_user_has_access(), 'core');
 
    // Is the logged in user is a mod for the current item?
    bp_update_is_item_mod(false, 'core');
 
    /**
     * Fires at the end of the setup of bp-core globals setting.
     *
     * @since BuddyPress 1.1.0
     */
    do_action('bp_core_setup_globals');
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.