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
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
| 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.