Skip to:
Content

BuddyPress.org

Changeset 12449


Ignore:
Timestamp:
08/22/2019 10:03:17 PM (5 years ago)
Author:
imath
Message:

Activity: make sure all late included files are successfully loaded

Using the BP_FRIENDS_SLUG or the BP_GROUPS_SLUG it is possible to customize the slug of corresponding single user's activity actions. As a result we need to map these potential customizable slugs with the filenames of PHP scripts late included.

Props Maniou

Fixes #8129

File:
1 edited

Legend:

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

    r12087 r12449  
    125125            }
    126126
    127             // Screens - User secondary nav.
    128             if ( bp_is_user() && in_array( bp_current_action(), array( 'friends', 'groups', 'favorites', 'mentions' ), true ) ) {
    129                 require $this->path . 'bp-activity/screens/' . bp_current_action() . '.php';
     127            /**
     128             * Screens - User secondary nav.
     129             *
     130             * For these specific actions, slugs can be customized using `BP_{COMPONENT}_SLUGS`.
     131             * As a result, we need to map filenames with slugs.
     132             */
     133            $filenames = array(
     134                'favorites' => 'favorites',
     135                'mentions'  => 'mentions',
     136            );
     137
     138            if ( bp_is_active( 'friends' ) ) {
     139                $filenames[bp_get_friends_slug()] = 'friends';
     140            }
     141
     142            if ( bp_is_active( 'groups' ) ) {
     143                $filenames[bp_get_groups_slug()] = 'groups';
     144            }
     145
     146            // The slug is the current action requested.
     147            $slug = bp_current_action();
     148
     149            if ( bp_is_user() && isset( $filenames[ $slug ] ) ) {
     150                require $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
    130151            }
    131152
Note: See TracChangeset for help on using the changeset viewer.