BP_Groups_Component::late_includes()

Late includes method.

Description

Only load up certain code when on specific pages.

Source

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

151
152
153
154
155
156
157
158
159
160
161
162
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
216
public function late_includes() {
    // Bail if PHPUnit is running.
    if ( defined( 'BP_TESTS_DIR' ) ) {
        return;
    }
 
    if ( bp_is_groups_component() ) {
        // Authenticated actions.
        if ( is_user_logged_in() &&
            in_array( bp_current_action(), array( 'create', 'join', 'leave-group' ), true )
        ) {
            require $this->path . 'bp-groups/actions/' . bp_current_action() . '.php';
        }
 
        // Actions - RSS feed handler.
        if ( bp_is_active( 'activity' ) && bp_is_current_action( 'feed' ) ) {
            require $this->path . 'bp-groups/actions/feed.php';
        }
 
        // Actions - Random group handler.
        if ( isset( $_GET['random-group'] ) ) {
            require $this->path . 'bp-groups/actions/random.php';
        }
 
        // Screens - Directory.
        if ( bp_is_groups_directory() ) {
            require $this->path . 'bp-groups/screens/directory.php';
        }
 
        // Screens - User profile integration.
        if ( bp_is_user() ) {
            require $this->path . 'bp-groups/screens/user/my-groups.php';
 
            if ( bp_is_current_action( 'invites' ) ) {
                require $this->path . 'bp-groups/screens/user/invites.php';
            }
        }
 
        // Single group.
        if ( bp_is_group() ) {
            // Actions - Access protection.
            require $this->path . 'bp-groups/actions/access.php';
 
            // Public nav items.
            if ( in_array( bp_current_action(), array( 'home', 'request-membership', 'activity', 'members', 'photos', 'albums', 'send-invites', 'subgroups' ), true ) ) {
                require $this->path . 'bp-groups/screens/single/' . bp_current_action() . '.php';
            }
 
            if ( in_array( bp_get_group_current_members_tab(), array( 'all-members', 'leaders' ), true ) ) {
                require $this->path . 'bp-groups/screens/single/members/' . bp_get_group_current_members_tab() . '.php';
            }
 
            // Admin nav items.
            if ( bp_is_item_admin() && is_user_logged_in() ) {
                require $this->path . 'bp-groups/screens/single/admin.php';
 
                if ( in_array( bp_get_group_current_admin_tab(), array( 'edit-details', 'group-settings', 'group-avatar', 'group-cover-image', 'manage-members', 'membership-requests', 'delete-group' ), true ) ) {
                    require $this->path . 'bp-groups/screens/single/admin/' . bp_get_group_current_admin_tab() . '.php';
                }
            }
        }
 
        // Theme compatibility.
        new BP_Groups_Theme_Compat();
    }
}

Changelog

Changelog
Version Description
BuddyPress 3.0.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.