BP_Messages_Component::late_includes()

Late includes method.

Description

Only load up certain code when on specific pages.

Source

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

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
public function late_includes() {
    // Bail if PHPUnit is running.
    if ( defined( 'BP_TESTS_DIR' ) ) {
        return;
    }
 
    if ( bp_is_messages_component() ) {
        // Authenticated actions.
        if ( is_user_logged_in() &&
            in_array( bp_current_action(), array( 'compose', 'notices', 'view' ), true )
        ) {
            require $this->path . 'bp-messages/actions/' . bp_current_action() . '.php';
        }
 
        // Authenticated action variables.
        if ( is_user_logged_in() && bp_action_variable( 0 ) &&
            in_array( bp_action_variable( 0 ), array( 'delete', 'read', 'unread', 'bulk-manage', 'bulk-delete' ), true )
        ) {
            require $this->path . 'bp-messages/actions/' . bp_action_variable( 0 ) . '.php';
        }
 
        // Authenticated actions - Star.
        if ( is_user_logged_in() && bp_is_active( $this->id, 'star' ) ) {
            // Single action.
            if ( in_array( bp_current_action(), array( 'star', 'unstar' ), true ) ) {
                require $this->path . 'bp-messages/actions/star.php';
            }
 
            // Bulk-manage.
            if ( bp_is_action_variable( 'bulk-manage' ) ) {
                require $this->path . 'bp-messages/actions/bulk-manage-star.php';
            }
        }
 
        // Screens - User profile integration.
        if ( bp_is_user() ) {
            require $this->path . 'bp-messages/screens/inbox.php';
 
            /*
             * Nav items.
             *
             * 'view' is not a registered nav item, but we add a screen handler manually.
             */
            if ( bp_is_user_messages() && in_array( bp_current_action(), array( 'compose', 'notices', 'view' ), true ) ) {
                require $this->path . 'bp-messages/screens/' . bp_current_action() . '.php';
            }
 
            // Nav item - Starred.
            if ( bp_is_active( $this->id, 'star' ) && bp_is_current_action( bp_get_messages_starred_slug() ) ) {
                require $this->path . 'bp-messages/screens/starred.php';
            }
        }
    }
}

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.