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

Set up component global variables.

Description

The BP_ACTIVITY_SLUG constant is deprecated, and only used here for backwards compatibility.

See also

Parameters

$args

(Optional) See BP_Component::setup_globals() for a description.

Default value: array()

Source

File: bp-activity/classes/class-bp-activity-component.php

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
public function setup_globals( $args = array() ) {
    $bp = buddypress();
 
    // Define a slug, if necessary.
    if ( ! defined( 'BP_ACTIVITY_SLUG' ) ) {
        define( 'BP_ACTIVITY_SLUG', $this->id );
    }
 
    // Global tables for activity component.
    $global_tables = array(
        'table_name'        => $bp->table_prefix . 'bp_activity',
        'table_name_meta'   => $bp->table_prefix . 'bp_activity_meta',
        'table_name_follow' => $bp->table_prefix . 'bp_follow',
    );
 
    // Metadata tables for groups component.
    $meta_tables = array(
        'activity' => $bp->table_prefix . 'bp_activity_meta',
    );
 
    // Fetch the default directory title.
    $default_directory_titles = bp_core_get_directory_page_default_titles();
    $default_directory_title  = $default_directory_titles[$this->id];
 
    // All globals for activity component.
    // Note that global_tables is included in this array.
    $args = array(
        'slug'                  => BP_ACTIVITY_SLUG,
        'root_slug'             => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
        'has_directory'         => true,
        'directory_title'       => isset( $bp->pages->activity->title ) ? $bp->pages->activity->title : $default_directory_title,
        'notification_callback' => 'bp_activity_format_notifications',
        'search_string'         => __( 'Search Feed…', 'buddyboss' ),
        'global_tables'         => $global_tables,
        'meta_tables'           => $meta_tables,
    );
 
    parent::setup_globals( $args );
 
    // locally cache total count values for logged-in user
    if ( is_user_logged_in() ) {
        $bp->loggedin_user->total_follow_counts = bp_total_follow_counts( array(
            'user_id' => bp_loggedin_user_id()
        ) );
    }
 
    // locally cache total count values for displayed user
    if ( bp_is_user() && ( bp_loggedin_user_id() != bp_displayed_user_id() ) ) {
        $bp->displayed_user->total_follow_counts = bp_total_follow_counts( array(
            'user_id' => bp_displayed_user_id()
        ) );
    }
}

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.